Skip to main content
The @urbackend/sdk package is the official TypeScript SDK for urBackend. It wraps the REST API with typed methods for auth, database, and storage — no manual fetch calls required.

Installation

Initialize the client

Import the default export and call it with your API key:
The factory accepts a UrBackendConfig object:

Quick example

TypeScript generics

Database methods accept a generic type parameter so returned documents are fully typed:

Error handling

Import the error classes to handle specific failure modes:

API key security

Use pk_live_... (publishable key) in frontend/browser code.
  • In public-read, reads work without a user token; writes require user token when RLS is enabled.
  • In private, both reads and writes require a user token.
Use sk_live_... (secret key) in server-side code only. It allows full CRUD access. Never expose it in client-side bundles or public repositories.
The SDK logs a console warning if it detects you are using a Secret Key (sk_live_...) in a browser context.

Explore the SDK

Auth

Login, logout, profile updates, and social auth.

Database

CRUD operations, query building, and RLS support.

Storage

Upload files and get back a public CDN URL.

Schema

Inspect collection definitions and field types.

Mail

Send transactional emails from your server.