Developers: SDK
SDK overview
The browser SDK every app ships with, and how to import it.
The browser SDK every app ships with, and how to import it.
Every app includes lib/draftship.ts, a dependency-free client for its backend.
"use client";
import { ds } from "@/lib/draftship";
| Module | What it does |
|---|---|
ds.entities.<Name> |
Create, read, update, delete and subscribe to records. |
ds.auth |
Sign up, sign in, current user, profile, sign out. |
ds.functions |
Call your backend functions. |
ds.agents |
Chat with in-app AI agents. |
ds.integrations.Core |
AI, images, uploads and email. |
ds.analytics |
Track custom events. |
Rules of thumb:
useEffect or event handlers.DraftshipError (with .status and a readable .message) on failure./_ds/... on the same origin. Exported apps use NEXT_PUBLIC_DRAFTSHIP_API, set automatically when exporting.For server code use the server SDK.