concile
Get Started

Quickstart

Get a concile backend running and watch it update live, in a few minutes.

In this quickstart, you will build a tiny backend with a messages table, a query that lists those messages, and a mutation that adds a new one. Then, you will watch the list update the exact moment you write a new row. It only takes a few minutes, and there are no skipped steps below.

Before you start

You will need Bun or Node.js 22.18+ and a package manager. Your backend will live in a folder called concile/. This is just the default name (since everything you import uses @concile/*), and you can easily change it later using the --dir flag.

Install concile

npx concile init my-app
cd my-app

init generates the project folder, sets up a concile/ directory with a sample messages schema, query, and mutation, and installs dependencies. In an empty folder, run npx concile init without a name, and it prompts you for one. Type . to use that folder. Working in an existing project? Run npx concile init directly in that repo. Run npx concile init --help to view all available flags.

Define a schema

init already wrote concile/schema.ts. Here is what is in it. It lists your tables and the shape of each row:

concile/schema.ts
import { defineSchema, defineTable, v } from "@concile/values";

export default defineSchema({
  messages: defineTable({
    author: v.string(),
    body: v.string(),
  }),
});

Every row also gets an _id and a _creationTime automatically, so you never declare those. The full list of field types (v.number(), v.id(...), v.optional(...), and so on) is in Schema & tables.

Write a query and a mutation

init already wrote concile/messages.ts. Here is what is in it:

concile/messages.ts
import { v } from "@concile/values";
import { query, mutation } from "./_generated/server";

// Reads data. Your app subscribes to this and gets live updates.
export const list = query({
  handler: (ctx) => ctx.db.query("messages", "by_creation").collect(),
});

// Writes data. Runs as one transaction.
export const send = mutation({
  args: { author: v.string(), body: v.string() },
  handler: (ctx, args) => ctx.db.insert("messages", args),
});

by_creation is a built-in index every table has, so list returns every message oldest-first with no index of your own.

Did you use --no-install? Then nothing is installed yet and init skips type generation. Install the packages it lists, then run npx concile codegen or npx concile dev.

Run it

npx concile dev

concile dev generates the typed concile/_generated/ helpers, starts the engine on a local SQLite file, serves a dashboard, and reloads whenever you edit a file. It prints its URL and a dev admin key:

concile dev → http://127.0.0.1:3000  (dashboard: http://127.0.0.1:3000/_dashboard)
admin key → 3q2xN7vRkYw8pTzL5mA9cB1dE6fGhJ0u

The admin key is a fresh random value on each run (unless you set CONCILE_ADMIN_KEY yourself). Yours will differ.

If you generated a starter app with init, run npm run dev. This boots both your app and the backend in separate terminal tabs. Use j and k to toggle between tabs, and hit q to shut down both processes. Next, open your app across two browser windows: http://localhost:5173 for React + Vite, or http://localhost:3001 for Next.js.

Watch it update live

You don't even need client code to see reactivity. The dashboard's data browser is itself a live subscription:

  1. Open the dashboard URL that concile dev printed.
  2. Open the data browser and select the messages table. Leave it on screen.
  3. Open the function runner and call messages:send with { "author": "Ada", "body": "hello" }.
  4. The new row shows up in the data browser right away, with no refresh.

That live view is a real reactive subscription (the dashboard subscribes to a built-in admin query, _admin:browseTable, over the same sync connection your app would use). A mutation wrote a row, and every subscription reading that table refreshed on its own, the dashboard's included. You wrote no polling and no invalidation code.

Connect a client

With the server running, point a client at the ws://127.0.0.1:3000/api/sync endpoint it opened:

App.tsx
import { ConcileClient, webSocketTransport } from "@concile/client";
import { ConcileProvider, useQuery, useMutation } from "@concile/client/react";
import { api } from "./concile/_generated/server";

const client = new ConcileClient(webSocketTransport("ws://127.0.0.1:3000/api/sync"));

function Messages() {
  const messages = useQuery(api.messages.list, {});
  const send = useMutation(api.messages.send);
  if (messages === undefined) return <p>Loading…</p>;
  return <ul>{messages.map((m) => <li key={m._id}>{m.author}: {m.body}</li>)}</ul>;
}

export function App() {
  return (
    <ConcileProvider client={client}>
      <Messages />
    </ConcileProvider>
  );
}

useQuery subscribes the component to the query. It returns undefined until the first result arrives, then re-renders on its own every time the result changes. That's the whole pattern.

See Client SDK for the full hook surface, and Tutorial for a complete app built this way.

Going deeper

Next steps

On this page