MainSDK
Search⌘K
Integrations

Typesense

Use Typesense for MainSDK search - self-hosted or cloud, API key, main.yaml, results scoped to the searcher, testing and swapping.

1 interface1 driverWritten guide
Updated 2026-10-28

Typesense is an open-source search engine, self-hosted or on Typesense Cloud, and the driver in the search examples. MainSDK limits every result to what the person searching may see. Pick it for fast, typo-tolerant search you can run in your own region.

Interfaces it serves

Pick Typesense in main.yaml for any of these. Your calls stay the same, and you can swap later.

Before you start

  1. Run Typesense yourself or create a Typesense Cloud cluster, in the region your records belong to.
  2. Create an API key for the app scoped to the collections and actions it needs, and store it in your secrets manager.

Configure

main.yaml
search:
  driver: typesense
  # key: secret:TYPESENSE_API_KEY   # suggested name; host and collection keys are [to be decided]

Use it

app/api/search/route.ts
import { auth, search } from "mainsdk";

export async function GET(req: Request) {
  const session = await auth.require(req);
  const q = new URL(req.url).searchParams.get("q") ?? "";
  return Response.json(await search.query({ q, for: session.user, limit: 10 }));
}

Local development and testing

Run Typesense in a container for development. A search fake for createTestApp() from @mainsdk/testing, and chaos.on("search", { outage: true }), arrive with the spec.

What MainSDK adds on top

Limits and notes

  • typesense is a planned search driver for phase 2; search has no spec yet.
  • An index is a copy of your data; keep personal and sensitive fields out unless needed, and keep the cluster in US, EU or India as your data requires.

Swap to or from it

main.yaml
search:
  driver: pgvector   # was typesense

FAQ

Typesense or pgvector? Both serve search. Typesense is a separate engine; pgvector runs inside your Postgres, so there is no second system to operate.

Next

Was this page helpful?

↑↓ moveEnter openEsc close

Not decided yet