Skip to content
SearchJet
Next.js Integration

Instant Search for Next.js — SSR, App Router & TypeScript Ready

AI-Powered Search for Modern React Applications

Add AI-powered search to your Next.js app in minutes. Works with App Router, Server Components, and static export.

The Problem

Next.js Search is Hard

Building search in Next.js means choosing between client-only libraries that don't scale, or complex Elasticsearch setups that hurt performance.

⚠

No Native Search

Next.js has no built-in search solution. You're left building custom Elasticsearch setups or piecing together client-only libraries that don't scale.

⚠

SSR Complexity

Client-only search libraries cause hydration mismatches. Getting server-rendered search results with proper SEO requires complex workarounds.

⚠

Performance at Scale

Large datasets kill client-side search performance. Filtering thousands of records in the browser blocks the main thread and hurts Core Web Vitals.

The Solution

SearchJet + Next.js

No SDK to install — plain fetch calls to a REST API that work in Server Components, route handlers, and client components. Built for the modern Next.js stack.

App Router & Server Components

Call the REST API with plain fetch from a Server Component. No SDK, no hydration issues, no use client directive needed for server-rendered results.

Server-Side Search

Fetch results in Server Components or route handlers for SEO-critical pages. Pre-render search results at build or request time.

TypeScript Friendly

No SDK types to learn. Responses are plain JSON (results, total, limit, offset), so a small interface describes your data shape.

Streaming + Suspense

Works with React 18 streaming and Suspense boundaries. Show search skeleton while results stream from the edge.

Static Export Compatible

The search API allows direct browser calls (CORS), so a search-only key works with static export. No server required for search.

Edge Runtime Ready

It is just fetch, so it runs on Vercel Edge Runtime and Cloudflare Workers. Sub-150ms search, called straight from the edge.

Built for Speed

Performance at Scale

<150ms
Avg Response Time
Typical query response
0
Database Load
Search runs externally
0
Extra Dependencies
Uses built-in fetch
99.5%
Uptime SLA
Monthly, on paid plans

SearchJet vs. Traditional Search

MetricDefault Next.jsAlgoliaSearchJet
Time to First Result1.5s+200ms<150ms
Typo ToleranceNoneYesAI-Powered
Monthly Cost (100K searches)Free$50/mo$79/mo (Growth)
SSR / SEO SupportManualPartialFull
Copy-Paste Integration

Two approaches for every Next.js architecture

Server Component (RSC)

app/search/page.jsx
// app/search/page.jsx — a Server Component: results are in the HTML, no client JS
const API = 'https://app.searchjetengine.com/api/v1';

export default async function SearchPage({ searchParams }) {
  const { q = '' } = await searchParams; // searchParams is a Promise in Next 15+

  let data = { results: [], total: 0 };
  if (q) {
    const res = await fetch(
      `${API}/search?q=${encodeURIComponent(q)}&limit=10`,
      {
        headers: { Authorization: `Bearer ${process.env.SEARCHJET_SEARCH_KEY}` },
        cache: 'no-store',
      }
    );
    if (res.ok) data = await res.json(); // { results: [...], total, limit, offset, ... }
  }

  return (
    <main>
      <form action="/search">
        <input name="q" defaultValue={q} placeholder="Search docs..." />
      </form>
      {q && <p>{data.total} results for "{q}"</p>}
      {data.results.map((hit) => (
        <article key={hit.id} className="p-4 border-b">
          <h3><a href={hit.url}>{hit.title}</a></h3>
          <p>{hit.excerpt}</p>
        </article>
      ))}
    </main>
  );
}

Route Handler + Client Component

app/api/search/route.js + components/LiveSearch.jsx
// app/api/search/route.js — proxies search so the key stays in an env var
export async function GET(request) {
  const q = request.nextUrl.searchParams.get('q') ?? '';
  const res = await fetch(
    `https://app.searchjetengine.com/api/v1/search?q=${encodeURIComponent(q)}&limit=10`,
    { headers: { Authorization: `Bearer ${process.env.SEARCHJET_SEARCH_KEY}` } }
  );
  return Response.json(await res.json(), { status: res.status });
}

// components/LiveSearch.jsx — search-as-you-type client component
'use client';
import { useEffect, useState } from 'react';

export default function LiveSearch() {
  const [q, setQ] = useState('');
  const [hits, setHits] = useState([]);

  useEffect(() => {
    if (!q) { setHits([]); return; }
    const controller = new AbortController();
    const timer = setTimeout(async () => {
      try {
        const res = await fetch(`/api/search?q=${encodeURIComponent(q)}`, {
          signal: controller.signal,
        });
        const data = await res.json();
        setHits(data.results ?? []); // results is the array of hits
      } catch {} // aborted or network error
    }, 200); // debounce keystrokes
    return () => { clearTimeout(timer); controller.abort(); };
  }, [q]);

  return (
    <div>
      <input value={q} onChange={(e) => setQ(e.target.value)} placeholder="Search docs..." />
      {hits.map((hit) => (
        <article key={hit.id} className="p-4 border-b">
          <h3><a href={hit.url}>{hit.title}</a></h3>
          <p>{hit.excerpt}</p>
        </article>
      ))}
    </div>
  );
}

Need a complete starter project?

View GitHub Examples
Illustrative Example

Before and After

Illustrative example of a Next.js app adding hosted search. Your results will vary.

MetricBeforeAfterImpact
Setup TimeWeeks (self-built search)HoursMuch faster to launch
Search Client Code80KB+ (Algolia)None — built-in fetchNo SDK to ship
Search SpeedSlower on large datasets<150msFaster results
Monthly CostsUsage-based (Algolia)$0-79 (Free to Growth)Predictable flat pricing

Frequently Asked Questions

Everything you need to know about SearchJet for Next.js

Does SearchJet work with Next.js App Router?
Yes. SearchJet is a REST API, so you call it with fetch from Server Components, route handlers, or client components. There is no package to install, and server-rendered results need no "use client" directive.
Is SSR supported?
Yes. Fetch results on the server in a Server Component or route handler and render them into the HTML for SEO-critical pages. On the Pages Router, the same fetch call works inside getServerSideProps.
Does it work with TypeScript?
Yes. The API returns plain JSON (results, total, limit, offset, page), so you can describe it with a small interface for your own data shape. No SDK types are required.
How do I add search to my Next.js app?
Create a search API key, add a route handler (app/api/search/route.js) that calls GET https://app.searchjetengine.com/api/v1/search with the key from an environment variable, then fetch it from a client component. Or fetch directly in a Server Component. See the code examples below.
Is there a demo I can try?
Yes, see our interactive demo at /vector-search-demo/ or check the GitHub examples repository for complete Next.js starter projects.
What about static export (SSG)?
Yes. The search API allows direct browser calls (CORS), so a statically exported site can query it client-side with a search-only key. Perfect for Jamstack deployments on Vercel, Netlify, or Cloudflare Pages. Never ship your private key to the browser.

Ready to Add Search to Your Next.js App?

Join developers building exceptional search experiences with SearchJet

Already have an account? Log in

Related Use Cases