NewWacht Bench is live — AI-assisted development for Wacht

Client access

The framework server SDKs expose the backend client through a small adapter layer. In Next.js, React Router, and TanStack Router, the main entrypoints are wachtClient() and createWachtServerClient(), depending on whether you want the cached default client or a fresh instance.

Usage

The following example shows a basic usage of the backend client from @wacht/nextjs/server.

import { wachtClient } from '@wacht/nextjs/server';export async function listUsers() {  const client = await wachtClient();  return client.users.listUsers({ limit: 10 });}

Framework adapters

In Next.js, React Router, and TanStack Router, the main helpers are wachtClient() and createWachtServerClient().
wachtClient() is the default entrypoint. It returns a cached backend client when you call it without options. createWachtServerClient() always creates a fresh backend client and is the better fit when you need explicit config for one code path.

How to choose

Use wachtClient() for ordinary framework-backed server calls. Use createWachtServerClient() when you need custom API keys, headers, base URLs, or a custom fetch implementation.
Both helpers access the same universal backend client surface. The difference is only how the framework package gives you that client.

Examples

Framework adapter: use the cached client

import { wachtClient } from '@wacht/nextjs/server';export async function GET() {  const client = await wachtClient();  const health = await client.health.healthCheck();  return Response.json(health);}

Framework adapter: create a fresh client

import { createWachtServerClient } from '@wacht/nextjs/server';export function createStagingClient(fetchImpl?: typeof fetch) {  return createWachtServerClient({    apiKey: process.env.WACHT_STAGING_API_KEY,    apiUrl: 'https://staging-api.wacht.io',    fetch: fetchImpl,    name: 'staging',  });}

On this page