How to Add Semantic Search to a Next.js Site Using Sanity's Native Embeddings
Sanity's native Embeddings feature, available on Growth and Enterprise plans as of mid-2026, enables vector-based semantic search directly within a dataset without requiring a separate service or manual infrastructure setup. Developers can configure which document types and fields get indexed through Sanity Studio or the Manage dashboard, and Sanity automatically backfills existing documents and re-embeds updated ones on publish. Semantic queries are executed using the dedicated GROQ function sanity::embeddings.query, which accepts a natural-language string and returns documents ranked by similarity. In a Next.js app, the recommended approach is to run these queries inside a server-side route handler to keep the Sanity read token out of the browser. The overall integration involves three steps: configuring the index, querying it via a Next.js API route, and rendering results in a client-side search UI component.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in