@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:UrBackendConfig object:
| Option | Type | Required | Description |
|---|---|---|---|
apiKey | string | Yes | Your project’s API key. |
baseUrl | string | No | Override the default API base URL. |
headers | Record<string, string> | No | Additional headers sent with every request. |
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:| Error class | HTTP status | When thrown |
|---|---|---|
AuthError | 401 / 403 | Invalid API key or missing token |
NotFoundError | 404 | Document or resource not found |
RateLimitError | 429 | Too many requests (100 req / 15 min per IP) |
ValidationError | 400 | Request body failed validation |
StorageError | varies | Storage-specific failures |
UrBackendError | varies | Base class for all SDK errors |
API key security
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.
Send transactional emails from your server.
