1. Create a Search Database#
Follow the instructions in the Getting Started guide to create a Search Database.
2. Project Setup#
Let's create a new Next.js application and install the @upstash/search package:
3. Add Environment Variables#
Find the environment variables from your database dashboard and add them to your .env file:
4. Create an API Route to Upsert Documents#
Create an API route in app/api/upsert/route.ts:
app/api/upsert/route.ts
5. Create a Route to Search Documents#
Create an API route in app/api/search/route.ts:
app/api/search/route.ts
6. Create a Simple Page#
Add the following code in app/page.tsx:
app/page.tsx
7. Start the Project#
Run the following command to start the development server:
Open your browser and navigate to http://localhost:3000 to test the application.
You can click the Upsert Data button to add three movies to your database and use the search bar to make a query.
Next Steps#
Learn more about: