Backend SDK

The backend SDK is the shared server-side surface behind the framework adapters and the standalone Node package. It is the universal JavaScript runtime SDK for privileged Wacht operations such as user management, organization and workspace management, API keys, webhooks, AI resources, notifications, OAuth, and utility endpoints.

Usage

The following example shows Rust backend usage with `wacht_rs`.

use wacht_rs::{Result, WachtClient};pub async fn example() -> Result<()> {    let client = WachtClient::builder()        .api_key(&std::env::var("WACHT_API_KEY")?)        .build()?;    let _users = client.users().fetch_users().send().await?;    Ok(())}

Signature

fn Backend SDK(  ) -> Result<(), wacht_rs::Error>

What it is

This is not a React hook surface. It is the backend management client your server code uses to call Wacht directly with an API key.
In Next.js, React Router, and TanStack Router, that client is exposed through wachtClient() and createWachtServerClient(). In the standalone backend package, the same underlying client is available directly through WachtClient plus the global helpers like initClient() and getClient().

Built for any JavaScript runtime

The backend client is designed to work anywhere you can run JavaScript on the server side. In modern runtimes with global fetch, it works directly. In runtimes that do not provide fetch, you can pass your own implementation through the client config.
That is why the same underlying client works across plain Node.js services, scripts, workers, serverless environments, and framework adapters.

How to think about the packages

@wacht/backend is the core backend SDK. It owns the client, the resource groups, the shared models, and the global client helpers.
The framework server packages are thin access layers over that same backend client. They mainly add environment lookup and a cached wachtClient() helper so framework code can get to the same universal backend surface more ergonomically.

Examples

Use the backend SDK directly in a JavaScript runtime

use wacht_rs::{Result, WachtClient};pub async fn example() -> Result<()> {    let client = WachtClient::builder()        .api_key(&std::env::var("WACHT_API_KEY")?)        .build()?;    let _health = client.health().check().send().await?;    Ok(())}

Provide fetch explicitly in a custom runtime

use wacht_rs::{Result, WachtClient};pub async fn example() -> Result<()> {    let client = WachtClient::builder()        .api_key(&std::env::var("WACHT_API_KEY")?)        .build()?;    let _result = client.Backend SDK(/* args */).send().await?;    Ok(())}

On this page