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.
- A 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 the app uses them.- Queries
- One file per query in
dbschema/queries, deployed by name. Your app callsmyNotesinstead of a custom route backed by hand-written handlers, andnapalm generateturns each query into a typed call in your language. - One client
- The client carries the signed-in session, keeps live queries current, reads the app’s own 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 an API server. Access rules run inside PostgreSQL for every caller, so a browser or phone calls the project directly and receives only the data the signed-in person may access. How Napalm works traces a request’s path.
Direct browser & phone callers
Web and mobile apps call the project endpoint directly with user sessions while compiled policies filter rows inside PostgreSQL.
Multiplexed live stream
Subscribed hooks share one POST /subscribe SSE stream and advance together at each commit without polling.
Local cache & reconnect sync
SQLite and IndexedDB stores serve cached rows without signal, queue idempotent writes and reconcile from Napalm-Bookmark on reconnect.
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.
| What you are building | Start with | Then |
|---|---|---|
| Anything, for the first time | Your first app | ThenA working app in a few minutes. The other guides build on this app. |
| A browser-direct React SPA | React, Vite & single-page apps | ThenPKCE sign-in across tabs, generated live hooks, direct uploads and deployed-query lockdown. |
| A web app with a server | Next.js & React | ThenSign-in in a cookie, pages rendered as the person, lists kept live. |
| A phone app in TypeScript | React Native | ThenThe web app’s client on a phone with Keychain sessions, live lists and disk uploads. |
| A phone app in Dart | Flutter | ThenSign-in through the system browser, live queries across the app’s lifecycle and resumable uploads. |
| A server beside the app | A backend service | ThenPython or Go calling the project as the requesting person or as the service. |
| Sign-up and sign-in | Sign-in for your app | ThenPasswords, magic links, providers, passkeys and session storage. |
| A product for teams | Multi-tenant B2B SaaS | ThenOrganizations, members and invites in one schema, spread across shards by organization. |
| Something people buy | Billing & payments | ThenPaid plans with Stripe, seat limits and prepaid credits that cannot be overdrawn. |
| Documents, media and search | Files, media & document search | ThenVerified multipart uploads, background PDF passage extraction and cited hybrid search. |
| Something people use together | Realtime & collaboration | ThenShared lists, instant edits, drag-and-drop ordering and active viewers. |
| Apps that work without signal | Offline caches & reconnect sync | ThenLocal SQLite or IndexedDB mirrors, idempotent offline outboxes and version conflict recovery. |
| Automated policy and query tests | Testing & verification | ThenCaller-matrix policy suites, dry-run write previews and pull-request CI gates. |
| Something about to launch | Environments & going live | ThenA development branch, a branch per pull request and the settings to lock down before launch. |
| Payments, email and background work | Actions & background jobs | ThenYour code, gated by a query and run as the caller immediately or on a schedule. |
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 triggering write.
Query-gated action handlers
A deployed gatekeeper query enforces caller access first, and matching rows wake your handler with a 60-second caller assertion and third-party secrets.
Transactional background jobs
Insert ext::napalm::Job in the same SQL transaction as your data write for durable retries and cron schedules.