Getting started
Quickstart
Read and write your first record in under five minutes.
This guide takes you from an empty project to a live, syncing record. It assumes you've already installed the client.
Connect
Create a client with your project URL and key. Keep the key in an environment variable, never in source.
ts
import { createClient } from "@quanta/client";
const quanta = createClient({
url: process.env.QUANTA_URL!,
key: process.env.QUANTA_KEY!,
});Write a record
ts
await quanta.collection("notes").set("welcome", {
title: "Hello, edge",
body: "Written once, read everywhere.",
});Subscribe to changes
Quanta pushes updates to every subscriber within ~40ms. Subscriptions are just async iterators.
ts
for await (const note of quanta.collection("notes").watch("welcome")) {
console.log("changed:", note.title);
}Subscriptions hold an open connection. Always break out of the loop when your component unmounts.