Examples
Run complete Ownfold examples for React, Next.js, TanStack Start, Express, Fastify, Elysia, Hono, and tRPC integrations.
Every supported framework boundary has a buildable example in the repository. Examples use
workspace packages while developing Ownfold; copy the same structure into an application and
replace workspace:* with released package versions.
Choose an example
| Stack | Example | What it proves |
|---|---|---|
| React + Vite | examples/vault-demo |
Application-owned private journal UI, recovery, IndexedDB, worker isolation, and accessibility. |
| Next.js + Auth.js + PostgreSQL | examples/next-auth-postgres |
Encrypted chat UI, email/password or GitHub sessions, App Router handlers, and PostgreSQL. |
| TanStack Start + Drizzle | examples/tanstack-start |
Full-stack encrypted journal, custom lifecycle controls, server routes, and Playwright. |
| Express + Better Auth + SQLite | examples/express-better-auth-sqlite |
Express 5 middleware, cookie sessions, Node bridge, SQLite, and shutdown. |
| Fastify + Better Auth + SQLite | examples/fastify-better-auth-sqlite |
Fastify handler, cookie sessions, body limits, SQLite, and injection tests. |
| Elysia + PostgreSQL | examples/elysia-postgres |
Bun server, native Web Request handling, custom bearer auth, and PostgreSQL. |
| Hono + Better Auth + PostgreSQL | examples/hono-better-auth-postgres |
Hono Node runtime, cookie sessions, ciphertext records, and PostgreSQL. |
| tRPC + SQLite | examples/trpc-sqlite |
v11 standalone router, Request context, vanilla typed client, and SQLite. |
Browser-only example
Use the React/Vite example to see headless hooks composed into a small private journal without configuring authentication or a database:
pnpm --filter @ownfold/example-vault-demo dev
This example uses in-memory coordination intentionally. Its markup and styles belong to the example, not the SDK. It is not a persistence architecture for deployment.
Full-stack examples
The Next.js and TanStack Start applications use the same SDK helpers but intentionally present different products and host-owned encrypted-record persistence.
cp examples/next-auth-postgres/.env.example examples/next-auth-postgres/.env.local
pnpm --filter @ownfold/example-next-auth-postgres devApply the Ownfold PostgreSQL migrations plus the example messages and credential-account migrations first. Email/password authentication works without an OAuth provider; GitHub remains optional.
pnpm --filter @ownfold/example-tanstack-start devThe Playwright configuration starts this example automatically for its full-stack test.
Backend examples
Backend-only examples expose /api/ownfold or a tRPC router without importing React or the browser
SDK. They can serve a browser client, another application process, a mobile client implementing the
protocol, or backend integration tests. Keep application record endpoints separate.
Each example includes environment validation, an application-owned authentication resolver, a real storage adapter in the runnable server, graceful shutdown where supported, and an integration test proving anonymous access is rejected.
Run all example checks
pnpm typecheck
pnpm test
pnpm -r --if-present build
pnpm test:browser
Backend tests use in-memory or isolated SQLite state. The real PostgreSQL release lane remains a separate disposable-database gate.
Security notes
Example credentials are placeholders. Never deploy them. Generate independent, high-entropy auth secrets. In browser E2EE examples, keep recovery secrets entirely in the browser. Examples choose different auth and database combinations to demonstrate composability; no framework requires that exact combination.
Ownfold examples persist only encrypted application payloads and lifecycle metadata. Adding a plaintext fallback column invalidates the security model even if the example continues to run.