Backend JS

Backend JS SDK

Universal JavaScript and TypeScript backend access to Wacht APIs, auth helpers, and gateway checks.

The backend package is @wacht/backend. It is framework-agnostic and works across server runtimes where fetch is available.

Use this SDK when you need:

  • server authentication and token verification
  • typed backend API access (users, org/workspace, webhooks, API auth, AI, settings)
  • gateway authorization checks
  • one shared client surface across scripts, workers, services, and framework adapters

Install

pnpm add @wacht/backend

Quick setup

import { initClient, users } from '@wacht/backend';

initClient({
  apiKey: process.env.WACHT_API_KEY!,
  baseUrl: process.env.WACHT_BACKEND_API_URL,
});

const response = await users.listUsers({ limit: 20 });
console.log(response.data.length);

How this relates to framework SDKs

Framework server packages (@wacht/nextjs/server, @wacht/react-router/server, @wacht/tanstack-router/server) are adapter layers over the same backend client surface.

  • framework adapters: use wachtClient() or createWachtServerClient()
  • standalone runtime usage: use initClient()/getClient() or new WachtClient(...)

For detailed comparisons, see:

Runtime guide groups

On this page