Build an offline event check-in app with Astro and SQLite
An entrance queue should keep moving when the network disappears. A useful check-in app needs a local attendee list, a durable record of each admission, and a way to reconcile devices afterward. A loading spinner cannot do that job.
This tutorial uses Fieldday, a fictional festival with North, South, and Artists entrances. Astro renders the command dashboard. Each entrance keeps its own SQLite database in the browser. Loomup stores the central roster and check-in events, then synchronizes the devices when they reconnect.
The example is a local, anonymous demo using fictional attendees. Offline sync is currently an opt-in preview. Use the walkthrough to understand the behavior before designing a production admission policy.
Run the example
You need Node.js 22.23.4 or newer, npm, and the Loomup CLI from the quickstart. Confirm that loomup --version works. Download the Fieldday example, extract it, and open a terminal in the fieldday directory.
cp .env.example .env
npm install
npm run backend
The backend command applies loomup.app.toml, seeds the fictional roster, and starts the local server. Keep it running. Open a second terminal in the same directory:
npm run dev
Visit http://127.0.0.1:4321. The default backend address is http://127.0.0.1:3000. Keep this first run on one computer; using other devices requires reachable server URLs and appropriate browser camera permissions. Manual ticket-code entry works without a camera.
The example pins released Loomup JavaScript packages to 0.1.28. You do not need to build or clone the SDK repository.
Separate attendees from admissions
The domain has two resources:
| Resource | What it records |
|---|---|
attendees | A person, their unique ticket code, and ticket type |
checkins | One admission event, including attendee, entrance, device, and time |
The distinction matters. If each device overwrote a shared checked_in boolean, the final row would hide the fact that two entrances admitted the same attendee. Separate check-in events preserve both observations. The command dashboard can then show a duplicate-entry warning.
Open loomup.app.toml to see the declarations. For example, the reference from an admission to an attendee is explicit:
[resources.checkins.fields.attendee_id]
type = "text"
required = true
references = "attendees"
index = true
Loomup applies the resource manifest to the central database. The browser SDK manages its own local storage; application code does not create internal sync tables. Read the resource guide for the complete manifest model.
Give each entrance a local database
In src/pages/entrance/[gate].astro, the browser opens an offline client for the roster and admissions. The essential setup looks like this:
import { createOfflineClient } from "@loomup/offline";
const offline = await createOfflineClient({
url: "http://127.0.0.1:3000",
database: "fieldday-north-gate.sqlite",
resources: ["attendees", "checkins"],
});
const attendees = offline.from("attendees");
const checkins = offline.from("checkins");
This is SQLite/WASM in the browser, with its binary snapshot persisted in IndexedDB. Each entrance uses a different database name. Storage belongs to the browser profile and origin; clearing site data removes the local copy and any pending work. It is not an independently backed-up server database.
Load each entrance while online so it can obtain the roster. Cached data enables offline use; a brand-new device cannot download attendees without a connection. The example does not install a service worker, so it also does not promise a cold page load without a network. Its offline control pauses synchronization in an already loaded page.
Record an admission locally
An admission creates a new check-in with a unique record ID. The offline SDK maintains a separate stable mutation identity for delivery retries. Here is the shape of the write; attendee is the selected cached roster record:
await checkins.create({
id: crypto.randomUUID(),
attendee_id: attendee.id,
entrance_id: "north",
entrance_name: "North Gate",
checked_in_at: Math.floor(Date.now() / 1000),
device_id: "north-demo-device",
});
The local UI updates optimistically. Show the pending queue and connection state so the operator can distinguish a locally recorded admission from one that has reached the server. The example subscribes to offline state changes and redraws those indicators.
Try a disconnected entrance
- Open Command in one tab and South Gate in another. Let the gate load its roster.
- Select Go offline at South Gate. This pauses that entrance's sync without disconnecting the whole computer.
- Admit attendees using the demo buttons or a ticket code. The gate's local count should change and its pending queue should grow.
- Look at Command. Those new events should not appear centrally yet.
- Select Reconnect. Pending admissions should upload, the queue should drain, and Command should receive the updates.
- Admit the same attendee at North Gate. Command should retain both events and show a duplicate-entry warning.
Use separate browser profiles when you want to distinguish device storage more clearly. For a persistence check, reload a gate after recording queued work, then inspect whether it survives and synchronizes. Remember that a reload resets the demo's in-memory network toggle: use the browser's network controls when testing an actual disconnected reload.
Decide what “duplicate” means
An HTTP retry of the same mutation and a second physical admission are different events. Retrying a stable mutation must not create another server write. Two entrances independently admitting the same person create two distinct events, even when both are delivered exactly once at the application level.
An offline entrance cannot know about an admission made moments ago on another disconnected device. Fieldday detects that conflict after reconciliation; it does not guarantee global duplicate prevention while offline. A real event may need online-only admission for some ticket types, gate-specific allocations, or a manual escalation procedure.
The next article explains retries, duplicate writes, and conflicts in more detail.
Before using real attendee data
The supplied demo deliberately allows anonymous resource access and permissive local CORS. Add operator authentication, scoped access rules, explicit allowed origins, and a retention policy before using real records. Decide which roster fields each device actually needs and how operators should recover pending work.
Start with the offline sync guide for persistence and conflict behavior, then the Astro integration guide for application integration. The most useful next step is to run the disconnected-entrance exercise and choose your own policy for an admission that two devices both accepted.