Quick Start

Spin up a minimal project and see live queries and optimistic updates in action.

🎯 Try This Example Live

See this code running in an interactive CodeSandbox environment with live examples of schemas, queries, and React integration.

Open CodeSandbox Demo →

Quick Navigation

Quick setup (Memory plugin)

import { DataStore } from "@routier/datastore";
import { MemoryPlugin } from "@routier/memory-plugin";
import { s } from "@routier/core/schema";

// Define a schema
const userSchema = s
  .define("users", {
    id: s.string().key().identity(),
    name: s.string(),
    email: s.string().distinct(),
  })
  .compile();

// Create a context (datastore) using the plugin
class AppContext extends DataStore {
  constructor() {
    super(new MemoryPlugin("routier-app"));
  }
  users = this.collection(userSchema).create();
}

const ctx = new AppContext();
await ctx.users.addAsync({ name: "Ada", email: "[email protected]" });
await ctx.saveChangesAsync();

What’s Next?