Guides · Start building
Building apps
An app on Napalm combines a schema, deployed queries and one generated client. These guides build common app architectures step by step.
- API
- —
- In the schema
- —
Parts of a Napalm app#
A Napalm app has three parts, and the first two live as files in your repository.
- Schema
dbschema/default.geldefines your types and the access rules on each type. Because sign-in, files and search are built into the project, the schema also declares how your app uses those features.- Queries
- Each file in
dbschema/queriesdeploys as a named query. Your app callsmyNotesinstead of a custom route handler, andnapalm generatecompiles each query into a typed call in your language. - Client
- The client carries the signed-in session, keeps live queries current, reads recent writes from any replica and uploads files straight to storage. Use the TypeScript or Dart SDK, or call the project’s HTTPS API from any language.
None of these parts is a custom API server. Access rules run inside PostgreSQL for every caller, so a browser or phone calls the project directly and receives only permitted rows. How Napalm works traces the full request path.
Direct client calls
Browsers and phones call your project directly while PostgreSQL filters every row.
Shared live stream
Active hooks share one SSE connection and update together at each commit.
Offline local sync
Local stores serve cached rows offline and reconcile changes when signal returns.
Starting points#
Choose the guide that matches your framework or product capability. Every guide builds on the same schema, deployed-query catalog and client session model.
| Goal | Start with | Coverage |
|---|---|---|
| Your first Napalm project | Your first app | CoverageBuild a working notes app with sign-in, live queries, file uploads and hybrid search. |
| A browser-direct React SPA | React, Vite & single-page apps | CoveragePKCE sign-in across tabs, generated live hooks, direct uploads and deployed-query lockdown. |
| A server-rendered React app | Next.js & React | CoverageHttpOnly cookie sessions, Server Components rendered as the user and live browser updates. |
| A mobile app in TypeScript | React Native | CoverageExpo and React Native with Keychain sessions, foreground live hooks and chunked disk uploads. |
| A mobile app in Dart | Flutter | CoverageKeychain sessions, lifecycle-aware live streams, SQLite caching and resumable file uploads. |
| A Python or Go backend | A backend service | CoverageForward caller bearer tokens, chain causal bookmarks, verify webhooks and run actions. |
| User authentication | Sign-in for your app | CoveragePasswords, magic links, OAuth providers, passkeys and session storage. |
| A multi-tenant SaaS product | Multi-tenant B2B SaaS | CoverageOrganizations, members, invites and SSO in one schema that scales across shards by organization. |
| Subscriptions and usage credits | Billing & payments | CoveragePaid plans with Stripe, schema-enforced seat limits and atomic credit wallets. |
| Documents, media and search | Files, media & document search | CoverageVerified multipart uploads, background PDF passage extraction and cited hybrid search. |
| Live collaboration | Realtime & collaboration | CoverageShared lists, optimistic moves, fractional drag-and-drop ordering and active viewers. |
| Offline-capable apps | Offline caches & reconnect sync | CoverageLocal SQLite or IndexedDB mirrors, idempotent mutation outboxes and conflict recovery. |
| Automated policy and query tests | Testing & verification | CoverageCaller-matrix policy suites, dry-run write previews and pull-request CI gates. |
| Environments and production launch | Environments & going live | CoverageDevelopment branches, pull-request preview branches and production endpoint lockdown. |
| External APIs and background jobs | Actions & background jobs | CoverageQuery-gated action handlers, transactional background jobs and cron schedules. |
Six additional shipping guides cover releases and day-two production operations across Release rehearsals, Live schema changes, Launch preparation, Production monitoring, Key and secret renewal and Rollbacks and restores.
Apps that need a server#
Because access policies run inside PostgreSQL on every request, an app never needs a custom server just to check permissions. Four cases call for a server or hosted handler alongside Napalm.
- Secrets
- Charging a card or sending an email requires a third-party secret that must not reach a browser. Use an action so a deployed query selects the permitted rows and your handler runs with the secret.
- Server rendering
- A server-rendering framework keeps the session in a cookie and calls the project as the signed-in person. Next.js & React shows the setup.
- Cookie sessions
- A session in a server’s
HttpOnlycookie stays out of reach of injected browser scripts. Sign-in for your app weighs the tradeoff. - Background work
- A nightly digest or delayed retry needs no separate server. Queue a job or schedule in the same commit as the write.
Actions & background jobs and A backend service show how server code and background work run under the caller’s schema permissions instead of a broad admin credential.
Query-gated actions
Gatekeeper queries check caller access before sending permitted rows to your handler.
Transactional background jobs
Jobs commit in the same transaction as your write and retry automatically.