Skip to main content
Integrate Moss semantic search into a Next.js application using Server Actions. This pattern keeps your API keys secure on the server while giving your frontend sub-10ms search results.
Note: For the complete demo application, see the Next.js example.

Why use Moss with Next.js?

Server Actions provide a clean boundary between client and server code. Moss runs server-side to keep credentials secure, while the client gets fast, relevant search results without managing API infrastructure or exposing keys.

Required tools

Integration guide

1

Installation

2

Environment setup

Create a .env.local file in your project root with your Moss credentials.
.env.local
3

Create a Server Action

Create a Server Action that initializes the Moss client, loads the index, and runs queries.
app/actions.ts
4

Call from a client component

Call the Server Action from any client component to display search results.
app/page.tsx