Upstash Documentation

Docs Search Quickstart

Add Upstash Search to your website in minutes
2 min read

Introduction#

Upstash Search makes it easy to add a fast, ready-to-use search bar to your docs site, no complex setup needed. In this tutorial, you’ll learn how to quickly integrate a modern search experience that helps your users find what they need. With just a few tweaks, you can use this solution in any project and deliver great search lightning fast.


1. Project Setup#

First, create an Upstash Search Database if you don't already have one (Getting Started guide) and then create a new Next.js application and install the related packages:


2. Add Environment Variables#

Find the environment variables from your database dashboard and add them to your .env file:


3. Create the Component#

Create the search component in app/components/search-bar.tsx:

app/components/search-bar.tsx

4. Crawl Docs to Feed the Component#

Call npx @upstash/search-crawler in your command line and follow the CLI, you will be prompted to provide:

  • Upstash Search URL (as set in your environment variables)
  • Upstash Search Rest Token (as set in your environment variables)
  • Upstash Search Index Name (Go for default for convenience)
  • Docs URL to crawl (Let's go for https://upstash.com/docs)
Note

If you prefer not to choose default index name, don't forget to update the line in the SearchComponent where you provide the index name.


5. Prepare the UI#

Replace the following code snippet with the code in app/page.tsx:

app/page.tsx

6. 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 search through Upstash docs, and results will redirect you to the page you are looking for.


Next Steps#

Learn more about: