Skip to the page

Guides · Start building

Your first app

napalm new scaffolds a notes app with sign-in, a live list, file uploads and search, and five commands take it live.

In the schema
—

What you’ll build#

You will build a browser-direct notes app with no custom server. People sign up with an email and password, keep notes synchronized across open tabs, attach files and search notes by both meaning and keywords. One command scaffolds the app, and five commands configure the project.

FeatureBuilt withFile
Sign-inBuilt-in email and password authFilesrc/SignInForm.tsx
Note ownershipSchema access policies per typeFiledbschema/default.gel
Live note listLive query subscriptionFilesrc/Notes.tsx
File attachmentsDirect upload from a file recordFilesrc/Files.tsx
Hybrid searchVector and full-text indexesFilesrc/Search.tsx

The other Apps guides start from this project. Next.js & React moves the app onto a server, and Realtime & collaboration shares notes between people.

Schema and policies

One schema file defines notes, attachments, search indexes and owner access rules.

Deployed queries

Named EdgeQL files deploy with the schema and generate typed React hooks.

Live subscriptions

Open tabs share one SSE stream and stay current without manual refetches.

Before you start#

Authenticated CLI
The quickstart installs the CLI and signs in with napalm login.
A Napalm project
napalm projects lists your projects. This guide uses a new project named notes. On a project that already has a schema, preview changes first with napalm schema push notes --plan.
Node.js 18 or later
Runs the local Vite dev server and code generator.

Make the app#

Terminal
napalm new notes-app notescd notes-app

napalm new scaffolds a Vite and React app in a new folder. Passing the project name writes its address to .env.local and prints tailored setup commands. The folder also includes AGENTS.md, CLAUDE.md and an .mcp.json file configured for the project’s MCP server.

Set the project up#

Run these five commands from the app folder. The output from napalm new includes your cluster name.

Terminal
# Push the schema and deploy every query in dbschema/queriesnapalm schema push notes # Enable the Project API for the local Vite dev servernapalm endpoint notes --enable --passthrough all --allow-origin http://localhost:5173 # Enable email and password sign-in without email verification during local setupnapalm sign-in set notes --app-name Notes --email-password --no-require-verification # Enable file storage on the project's clusternapalm storage enable <cluster> files # Check enabled features and any remaining setup commandsnapalm status notes
--allow-origin
The Project API answers browser requests only from listed origins, including the port, so the Vite dev server stays on port 5173.
--passthrough all
Allows user sessions to send ad-hoc EdgeQL statements. The starter app uses an ad-hoc statement only for the search box and calls deployed queries everywhere else. Passing --passthrough keys restricts user sessions to deployed queries once search moves into dbschema/queries.
--no-require-verification
Skips email confirmation during local setup so you do not need an SMTP server (napalm sign-in email) yet. Enable email verification before real users sign up.

Run the app#

Terminal
npm installnpm run dev

Open http://localhost:5173, sign up and add a note.

Look inside the app#

  1. One policy enforces note ownership

    The schema declares one access policy per type to restrict each note and file to its owner. Client code never checks permissions because every query, live subscription and search runs under that policy, so PostgreSQL filters out unreadable notes.

    dbschema/default.gel
    # Napalm's extension brings auth and ai. This schema declares them too, for the types the schema uses.using extension auth;using extension ai;using extension files;using extension napalm;using future simple_scoping; module default {  # Whoever is asking: the identity of the session a call came with. Nobody, for a call with no session.  global caller := global ext::auth::ClientTokenIdentity;   # Napalm's own embedding provider: there's no key to set, and what it embeds is on your bill.  abstract type NapalmEmbedding extending ext::ai::EmbeddingModel {    annotation ext::ai::model_name := 'openai/text-embedding-3-small';    annotation ext::ai::model_provider := 'napalm';    annotation ext::ai::embedding_model_max_input_tokens := '8191';    annotation ext::ai::embedding_model_max_batch_tokens := '8191';    annotation ext::ai::embedding_model_max_output_dimensions := '1536';    annotation ext::ai::embedding_model_supports_shortening := 'true';  }   type Note {    required owner: ext::auth::Identity;    required title: str;    required body: str;     # A search reads both: the first finds a note by its meaning, the second by its words.    deferred index ext::ai::index(embedding_model := 'openai/text-embedding-3-small')      on (.title ++ '\n\n' ++ .body);    index fts::index on ((      fts::with_options(.title, language := fts::Language.eng, weight_category := fts::Weight.A),      fts::with_options(.body, language := fts::Language.eng, weight_category := fts::Weight.B)    ));     # The one rule: a note is its owner's. Every query, live query and search runs under it.    access policy owner_has_full_access      allow all      using (.owner ?= global caller);  }   # A file is a record: its bytes are in the project's bucket, and the same kind of rule says who may have them.  type Attachment extending ext::files::File {    required owner: ext::auth::Identity;     access policy owner_has_full_access      allow all      using (.owner ?= global caller);  }}
  2. The client manages the session

    SignIn stores the active session, and NapalmClient attaches the bearer token to every request. When a user signs in or out, the client clears cached rows and restarts live subscriptions under the new identity.

    src/napalm.ts
    // src/napalm.tsimport { NapalmClient, SignIn, webStore } from 'napalm-client' /** Project HTTPS URL from .env.local (printed by `napalm endpoint <project>`). */export const address = import.meta.env.VITE_NAPALM_URL as string /** Browser session manager backed by Web Storage. */export const signIn = new SignIn(address, { store: webStore() }) /** Shared client that attaches the active session and resubscribes live queries when auth state changes. */export const napalm = new NapalmClient(address, { signIn }) /** * Run a deployed query by name as the signed-in caller. Run `npm run generate` to emit * typed functions and hooks for every file in dbschema/queries. */export async function call<Row>(name: string, variables: Record<string, unknown> = {}): Promise<Row[]> {  const response = await napalm.fetch(`${address}/query/${name}`, {    method: 'POST',    headers: { 'Content-Type': 'application/json' },    body: JSON.stringify({ variables }),  })  const answer = await response.json()  if (!response.ok) throw new Error(answer.error?.message ?? answer.error?.code ?? response.statusText)  return answer.data}
  3. Live queries keep the list current

    The query carries no owner filter because the access policy restricts rows to the caller’s notes automatically.

    dbschema/queries/myNotes.edgeql
    # Select the caller's notes (Note's access policy filters rows automatically).select Note { id, title, body }order by .title

    useLiveQuery returns the query rows and keeps the list current. Adding a note requires only the insert call and needs no manual refetch.

    src/Notes.tsx
    // src/Notes.tsximport { deployed } from 'napalm-client'import { useLiveQuery } from 'napalm-client/react'import { useState, type FormEvent } from 'react'import { call } from './napalm' type Note = { id: string; title: string; body: string } /** Reference to the deployed query in dbschema/queries/myNotes.edgeql. */const myNotes = deployed<Note, Record<string, never>>('myNotes') export function Notes() {  // Subscribes to live row diffs across tabs and callers. Note's access policy  // runs inside the subscription, returning only the signed-in user's notes.  const { rows, error, isLoading } = useLiveQuery(myNotes, {})  const [title, setTitle] = useState('')  const [body, setBody] = useState('')   const add = async (event: FormEvent) => {    event.preventDefault()    await call('addNote', { title, body })    setTitle('')    setBody('')  }   return (    <section>      <h2>Your notes</h2>      <form onSubmit={add}>        <input placeholder="Title" value={title} onChange={(event) => setTitle(event.target.value)} required />        <input placeholder="Body" value={body} onChange={(event) => setBody(event.target.value)} required />        <button type="submit">Add</button>      </form>      {error && <p role="alert">{error.message}</p>}      {isLoading ? (        <p>Loading…</p>      ) : (        <ul>          {rows?.map((note) => (            <li key={note.id}>              <strong>{note.title}</strong> {note.body}            </li>          ))}        </ul>      )}    </section>  )}
  4. Files pair a database row with direct upload

    Setting a file’s byte size in a mutation returns a one-time upload plan. napalm.upload then streams the file straight to object storage and splits large files into parallel parts. The same access policy governs download links.

    dbschema/queries/addFile.edgeql
    # Insert an Attachment with file_size to receive a one-time file_upload target.select (insert Attachment {  owner := global caller,  file_name := <str>$name,  file_size := <int64>$size,}) { id, file_upload }
  5. Hybrid search combines semantic and keyword indexes

    The Note type declares an ext::ai::index for semantic search and an fts::index for keyword search. napalm.search('Note', query) fuses both indexes under the same access policy, so only the caller’s own notes can match.

Add your own query#

Each query lives in dbschema/queries, and its file name becomes the call name. Save the query below as titlesStarting.edgeql.

dbschema/queries/titlesStarting.edgeql
# Select the caller's notes matching a title prefix.select Note { id, title }filter .title ilike (<str>$start ++ '%')order by .title
Terminal
napalm schema push notesnpm run generate

Pushing deploys the query and refuses any schema change that would break a deployed query. npm run generate writes a typed call and a live hook for each query into src/generated so your components use generated types instead of untyped call.

src/Titles.tsx
// src/Titles.tsximport { useTitlesStarting } from './generated/hooks' export function Titles({ start }: { start: string }) {  // Typed from the query: start is a string, and each row has an id and a title.  const { rows } = useTitlesStarting({ start })  return (    <ul>      {rows?.map((note) => (        <li key={note.id}>{note.title}</li>      ))}    </ul>  )}

Check the app#

  1. Open a second tab

    Add a note in one tab. The note appears in the other tab without a reload.

  2. Sign up as someone else in a private window

    The second account sees an empty list, and searching for a word from the first user’s note returns zero matches. PostgreSQL enforces that separation without application filter code.

  3. Check the project status

    napalm status notes confirms every feature is enabled, and napalm people reach counts the rows a given user can read or write on each type.

Next steps#

Sign-in for your app
Magic links, Google and GitHub, passkeys, address confirmation and session storage.
Realtime & collaboration
Shared notes, drag-and-drop ordering and active viewers.
React, Vite & single-page apps
Cross-tab PKCE sessions, generated live hooks, direct browser uploads and deployed-query lockdown.
Next.js & React
Move sessions into HttpOnly cookies, render pages on the server as the user and keep browser lists live.
Files, media & document search
Multipart file progress, background PDF passage extraction and cited hybrid search.
Testing & verification
Caller-matrix access tests, dry-run write previews and pull-request CI gates.
Environments & going live
Create development branches, preview pull requests and lock down endpoints before launch.
Schema
Model custom types, links, constraints and access policies.

Type a word or two to search every docs page.