Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Client-based Search on Strapi Static Sites with Next.js, Fuse.js, and Cloudflare #1512

Closed
1 task done
win-ne opened this issue Aug 9, 2024 · 16 comments
Closed
1 task done
Assignees
Labels

Comments

@win-ne
Copy link

win-ne commented Aug 9, 2024

What is your article idea?

Strapi provides a host of search APIs. There are also several third-party services that one could integrate Strapi with for more fine-grained search functionality like Algolia. But I was hoping to propose an alternative search method that is client-based, that does not rely on external calls to Strapi or any third-party services, has great performance, and would work well with static sites that host Strapi content.

What are the objectives of your article?

Client-based Multi-field Search and Filtering on Strapi Static Sites with Next.js, Fuse.js, and Cloudflare

1. Introduction

  • Importance of search and filtering as features
  • Use cases for search
  • Benefits of forgoing third-party search services
  • Limitations for this kind of search
  • Introduce real-life example to illustrate search - a publication
  • Introduce fuse

2. Setup up your Strapi backend

  • Create a Strapi backend
  • Setup several related multi-field Strapi content types
  • Adding Strapi webhooks for different events
  • Add sample data to search

3. Setting up your Next.js app

  • Building and updating a search index for faster search
  • Make a service to handle search
  • Creating a search results page
  • Creating a filtering component

4. Deployment

  • Setup deployment on Cloudflare
  • Create a deployment hook to rebuild site and index when Strapi content changes
  • Setup caching for the index

5. Conclusion

  • Summarize what was covered in the article
  • Highlight key takeaways from the tutorial
  • Mention a point or two about Strapi and its features

Technologies

  • Strapi V5 - as the headless CMS
  • Next.js - as the frontend and for generating an SSG site
  • Fuse.js - to provide search and search indexing functionality
  • Cloudflare - for hosting
  • Tailwind - for styling

User Story

A publication reader would want to search for content by titles, keywords, authors, tags, and categories so that they can quickly find content that matches their interests. They need a quick and seamless search experience that allows them to filter results based on multiple criteria. This will help them easily discover relevant content without navigating through multiple pages.

Article Objectives

  • Provide alternatives to external search services and search calls to Strapi that work well for static sites
  • Illustrate a more straightforward versatile means to search Strapi content with an easier learning curve
  • Help developers cut costs and improve performance in their applications when it comes to search

What is your expertise as a developer or writer?

Intermediate

What type of post is this?

Tutorial

Terms & Conditions

  • I have read the Write for the Community program guidelines.
@Theodore-Kelechukwu-Onyejiaku
Copy link
Collaborator

Hi @winnie-n ,

Thanks for your article outline. I can't wait to see more of your contributions 🚀

I think your suggestions looks similar to these:

Please let me know if I am missing something. Thank you,

@win-ne
Copy link
Author

win-ne commented Aug 9, 2024

You're right @Theodore-Kelechukwu-Onyejiaku . Really appreciate your feedback and you catching those. I'll review the blog more carefully before proposing an idea. Thanks again. Closing it now.

@win-ne win-ne closed this as completed Aug 9, 2024
@Theodore-Kelechukwu-Onyejiaku
Copy link
Collaborator

Thank you @winnie-n .

Please feel free to propose another one in the future. Thank you!

@win-ne
Copy link
Author

win-ne commented Aug 9, 2024

Hey @Theodore-Kelechukwu-Onyejiaku.

Apologies for the earlier typos.

After reading the articles you shared, I’m considering a different angle for the search and filtering features. I propose a client-based approach, ideal for statically generated sites like news sites, blogs, and static e-commerce stores, where no external API calls to Strapi are needed. The content would still be managed on Strapi, with the search index updated and generated as a static asset whenever content changes and the site is rebuilt.

This approach would really appeal to developers working on Jamstack sites. What do you think?

@win-ne win-ne reopened this Aug 9, 2024
@win-ne win-ne changed the title Multi-field Search and Filtering on Strapi Content Without Relying on Third-Party Services with Next.js Client-based Multi-field Search and Filtering on Strapi Content with Next.js and Fuse.js Aug 12, 2024
@win-ne win-ne changed the title Client-based Multi-field Search and Filtering on Strapi Content with Next.js and Fuse.js Client-based Multi-field Search and Filtering on Strapi Content on Static Sites with Next.js, Fuse.js, and Cloudflare Aug 12, 2024
@win-ne win-ne changed the title Client-based Multi-field Search and Filtering on Strapi Content on Static Sites with Next.js, Fuse.js, and Cloudflare Client-based Multi-field Search and Filtering on Strapi Static Sites with Next.js, Fuse.js, and Cloudflare Aug 12, 2024
@Theodore-Kelechukwu-Onyejiaku
Copy link
Collaborator

Hi @winnie-n , thank you.

Could you please elaborate on "with the search index updated and generated as a static asset whenever content changes and the site is rebuilt."

Also, previously, were you intending on adding indexes to Strapi? And what will be the purpose of Fuse.js and Cloudflare?

@win-ne
Copy link
Author

win-ne commented Aug 14, 2024

Thank you for following up @Theodore-Kelechukwu-Onyejiaku .

Developers often opt for static websites because they perform better and load faster. So I wanted to show how to make search somewhat static and faster too. It's slower when you have to make a search request to a server.

  • The search index is built at the same time as the website.
  • It is hosted as a static asset on the hosting service (Cloudflare), the same as the website pages.
  • There is no need to request a search on a service like Algolia or the Strapi API. Search is entirely client-based. Hence, it's faster.
  • Only the publication content is hosted on Strapi. The search index is hosted as a static asset on Cloudflare. It's delivered together with the static site.

Regarding Fuse and Cloudflare:

  • Fuse performs the search and helps build the search index. It's a search library.
  • Cloudflare is the hosting service. It rebuilds both the website and the search index as static assets when the Strapi content changes. It then hosts it on its CDN.

@Theodore-Kelechukwu-Onyejiaku
Copy link
Collaborator

This sounds interested. Please proceed.

Please don't forget to use Strapi 5. Thank you.

Meanwhile, you can please update the title of this article idea to reflect the purpose of your work.

@Theodore-Kelechukwu-Onyejiaku Theodore-Kelechukwu-Onyejiaku added the In progress Tutorial being created label Aug 20, 2024
@Theodore-Kelechukwu-Onyejiaku
Copy link
Collaborator

Depending on the effort put into this article, I might have to label it as "intermediate".

@win-ne
Copy link
Author

win-ne commented Aug 26, 2024

Got it. Thank you @Theodore-Kelechukwu-Onyejiaku .

@win-ne win-ne changed the title Client-based Multi-field Search and Filtering on Strapi Static Sites with Next.js, Fuse.js, and Cloudflare Client-based Search on Strapi Static Sites with Next.js, Fuse.js, and Cloudflare Nov 11, 2024
@Theodore-Kelechukwu-Onyejiaku
Copy link
Collaborator

Hi @winnie-n , please would you be willing to turn in this article by this week or next?

@win-ne
Copy link
Author

win-ne commented Nov 12, 2024

Hey @Theodore-Kelechukwu-Onyejiaku . Yes. I'll turn it in before the end of day tomorrow. Finished the code project, just writing up the article now.

@win-ne
Copy link
Author

win-ne commented Nov 15, 2024

Hi @Theodore-Kelechukwu-Onyejiaku . Here it is. I've shared everything with you.

  1. HackMD draft
  2. Project source
  3. Project deployed for previewing purposes and the search feature itself

Depending on the effort put into this article, I might have to label it as "intermediate".

Could I possibly get a label review?

@win-ne win-ne changed the title Client-based Search on Strapi Static Sites with Next.js, Fuse.js, and Cloudflare Browser-based Search on Strapi Static Sites with Next.js, Fuse.js, and Cloudflare Nov 19, 2024
@win-ne win-ne changed the title Browser-based Search on Strapi Static Sites with Next.js, Fuse.js, and Cloudflare Client-based Search on Strapi Static Sites with Next.js, Fuse.js, and Cloudflare Nov 19, 2024
@Theodore-Kelechukwu-Onyejiaku
Copy link
Collaborator

Thank you very much @win-ne ,

I will now add this to the review backlog.

@Theodore-Kelechukwu-Onyejiaku Theodore-Kelechukwu-Onyejiaku added In Review Article is in review and removed In progress Tutorial being created labels Nov 19, 2024
@Theodore-Kelechukwu-Onyejiaku
Copy link
Collaborator

Hi @win-ne ,

Trust you are doing well. Could you please ping me the following on Discord:

  • Full Name
  • Photo
  • Email Address
  • Bio
  • Job Title
  • Twitter Handle

Thank you for your contribution! 💪

@Theodore-Kelechukwu-Onyejiaku
Copy link
Collaborator

Hi @win-ne ,

I added some comments to you draft. Could you please review and incorporate. Thank you.

@Theodore-Kelechukwu-Onyejiaku
Copy link
Collaborator

Hi @win-ne ,

Trust you are doing great. Just to remind you of the messages above. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants