Server SDK
Self-host Teardown's identify, events, force-update, and version management runtime inside your own TypeScript backend, backed by your own database.
The Teardown Server SDK (@teardown/server) lets you run Teardown's device/user identify, event ingestion, force-update / version-status checks, and app version & build management runtime inside your own TypeScript backend, backed by your own database.
It pairs with the React Native SDK: point its ingestUrl at a server running @teardown/server and the existing client works unchanged.
Features
- Self-hosted ingest - Run the
POST /v1/identifyandPOST /v1/eventswire contract the React Native SDK speaks, in your own service - Force updates from your backend - Version-status checks resolved against your data, plus version & build management (status cascade + change hooks)
- Bring your own database - Implement a small storage interface for any database (Postgres, MongoDB, Firestore, …); you own the schema and migrations. An in-memory adapter ships for tests and prototyping
- Two consumption modes - Mount a ready-made HTTP router, or call the domain services directly from your own routes and auth
- Runtime-agnostic - Web-standard
fetchadapter runs on Bun, Hono, Deno, Cloudflare Workers, and Next.js route handlers; a first-class Elysia plugin is also shipped - No singletons, full DI - Everything is wired through
createTeardown; nothing reads a module-leveldb/cache/logger - Type Safety - Full TypeScript types for the storage ports, entities, configuration, and HTTP contract
Quick Start
Install the package:
bun add @teardown/serverGenerate a SESSION_SECRET (openssl rand -base64 32), wire a storage layer into the
runtime, then mount the ingest router:
import { createTeardown } from "@teardown/server";
import { createMemoryStorage } from "@teardown/server/adapters/memory";
import { toFetchHandler } from "@teardown/server/http/fetch";
const td = createTeardown({
storage: createMemoryStorage(), // in-memory for tests; implement the repositories for production
config: { sessionSecret: process.env.SESSION_SECRET! },
});
// Bun example — serve the ingest contract the RN SDK speaks:
Bun.serve({ port: 4501, fetch: toFetchHandler(td.router()) });The Getting Started guide walks this end to end — generating the secret, seeding a project/environment, running single-tenant, and going to production by implementing the storage repositories.
Then point the React Native SDK at your server with the self-hosted config:
const teardown = new TeardownCore({
config: { type: "self-hosted", ingestUrl: "https://ingest.your-app.com" }, // your @teardown/server endpoint
environment_slug: "production",
// ...storageAdapter, deviceAdapter
});Runtime support
The primary fetch adapter has zero required peer dependencies and runs anywhere Web-standard Request/Response is available. An Elysia plugin is shipped for Elysia hosts.
| Runtime | Adapter | Import |
|---|---|---|
Bun (Bun.serve) | fetch | @teardown/server/http/fetch |
| Elysia | Elysia plugin | @teardown/server/http/elysia |
| Hono | fetch | @teardown/server/http/fetch |
| Cloudflare Workers / Deno / edge | fetch | @teardown/server/http/fetch |
| Next.js route handlers | fetch | @teardown/server/http/fetch |
| Node / Express | fetch (via a Web Request shim) | @teardown/server/http/fetch |
Documentation
- Getting Started - Install, generate a session secret, run with in-memory storage, connect the client, then implement the repositories for production
- Core Concepts - Ports & adapters architecture and the two consumption modes
- Storage - The
TeardownStorageport, the in-memory adapter, and bringing your own database - Mounting - The HTTP layer, adapters, CORS, and the request/response contract
- Version Management - Managing versions/builds and force-update status from your backend
- API Reference -
createTeardown, theTeardownobject, services, and ports - Advanced - Caching, logging, metrics, atomicity, and deployment