This is a simple Next.js app that implements a search query using Next.js API routes
- clone the repo and
cdinto the directory - run
npm installto install dependencies - run
npm run devto start the development server
The search query is implemented in 3 steps:
- A json file at the root of the project called
posts.jsonthat contains an array of posts with their id and title - An API route that accepts a query parameter and returns the matching posts from the
posts.jsonfile - A search component that uses fetch to call the API route and displays the results
- Open the app in your browser
- Type in the search bar the post title that you need to search and click on the search button
- The results will be displayed below the search bar
Note: Check
posts.jsonto see the available post titlesEXAMPLE SEARCHES:
"first post","post",""
