### Install and Run Project Source: https://github.com/garden-co/jazz/blob/main/starters/next-localfirst/README.md Install project dependencies and start the development server. ```bash pnpm install pnpm dev ``` -------------------------------- ### Install and Run Development Server Source: https://github.com/garden-co/jazz/blob/main/examples/chat-react/README.md Installs project dependencies and starts the Jazz server along with the Vite development environment. ```bash pnpm install pnpm dev # starts the Jazz server, pushes the schema, and opens Vite ``` -------------------------------- ### Install insta CLI Source: https://github.com/garden-co/jazz/blob/main/dev/CONTRIBUTING.md Install the insta command-line interface globally using cargo. This is a one-time setup. ```sh # Install the insta CLI (once) cargo install cargo-insta ``` -------------------------------- ### HTML Setup for TypeScript Quickstart Source: https://github.com/garden-co/jazz/blob/main/docs/content/docs/install/client.mdx Basic HTML structure for a TypeScript application using Jazz. This includes the root element where the app will be mounted. ```html Vite + React + TS
``` -------------------------------- ### Running the Authentication Server CLI Source: https://github.com/garden-co/jazz/blob/main/docs/content/docs/auth/authentication.mdx This command starts the Jazz authentication server. Ensure you have the necessary dependencies installed and configured. ```bash ../examples/docs/todo-server-ts/docs/auth-server-cli.sh#auth-server-cli ``` -------------------------------- ### Install Dependencies and Prebuild Expo Project Source: https://github.com/garden-co/jazz/blob/main/dev/stress-tests/stress-test-expo/README.md Navigate to the Expo project directory, install its dependencies, and prebuild the project. This prepares the native iOS/Android projects. ```bash cd examples/stress-test-expo pnpm i pnpm expo prebuild --clean ``` -------------------------------- ### Build and Start Production Server Source: https://github.com/garden-co/jazz/blob/main/starters/react-betterauth/README.md Commands to build the application for production and start the Hono server. The server handles both the SPA and API routes. ```bash pnpm build pnpm start ``` -------------------------------- ### Provider Setup Source: https://github.com/garden-co/jazz/blob/main/packages/jazz-tools/bin/docs-index.txt Wrap your application with the Jazz Provider to make the database accessible to all components. Examples are provided for React/Expo, Vue, and Svelte. ```APIDOC ## Provider Setup Wrap your app in a provider to make the database available to every component. ### React / Expo ```tsx import { JazzProvider } from "jazz-tools/react"; import { createJazzClient } from "jazz-tools"; const client = createJazzClient({ appId: "my-app", }); function App() { return ( ); } ``` ### Vue ```vue ``` ### Svelte ```svelte {#snippet children({ db })} {/snippet} {#snippet fallback()}

Loading...

{/snippet}
``` ``` -------------------------------- ### Install Dependencies Source: https://github.com/garden-co/jazz/blob/main/docs/content/docs/install/typescript-server.mdx Installs necessary Jazz, Hono, and TypeScript dependencies for the server project. ```bash pnpm add jazz-tools@alpha jazz-napi@alpha hono @hono/node-server pnpm add -D typescript tsx ``` -------------------------------- ### Server Setup Source: https://github.com/garden-co/jazz/blob/main/docs/content/docs/install/typescript-server.mdx Initializes the Jazz server with application ID, schema, permissions, and server configuration. ```typescript import { Hono } from "hono"; import { serve } from "@hono/node-server"; import { Db, createServer } from "jazz-tools"; import schema from "./schema.js"; import permissions from "./permissions.js"; const appId = "019d0ba1-519a-7e01-b0eb-0059ee898e4d"; // Replace with your generated App ID const app = new Hono(); const server = createServer({ appId, schema, permissions, // For local development, use the persistent driver driver: Db.persistent({ dataPath: "./.jazz", // Directory for local database files }), // For production, use a remote server URL and backend secret // serverUrl: "https://your-jazz-server.com", // backendSecret: "your-backend-secret", // jwksUrl: "https://your-jazz-server.com/.well-known/jwks.json", }); // Middleware to attach the Jazz context to each request app.use("/*", server.middleware()); // Routes app.get("/", (c) => { return c.text("Hello Jazz!"); }); // Start the server console.log("Server listening on port 3000"); serve({ fetch: app.fetch, port: 3000 }); ``` -------------------------------- ### TypeScript: Quickstart Permissions Source: https://github.com/garden-co/jazz/blob/main/docs/content/docs/install/client.mdx Define permissions to allow all reads and writes for the quickstart. This is necessary for the server to accept operations. ```ts import { defineSchema, definePermissions, } from "@/index"; const schema = defineSchema({ todos: { id: "uuid", text: "string", isDone: "boolean", }, }); export const permissions = definePermissions({ read: ["todos"], insert: ["todos"], update: ["todos"], delete: ["todos"], }); ``` -------------------------------- ### Start Self-Hosted Jazz Database Server Source: https://github.com/garden-co/jazz/blob/main/packages/jazz-tools/bin/docs-index.txt Use this command to start a local Jazz database server. Configure port, data directory, and authentication secrets as needed. ```bash #!/usr/bin/env bash npx jazz-tools@alpha server "$JAZZ_APP_ID" \ --port 1625 \ --data-dir ./data \ --admin-secret "$JAZZ_ADMIN_SECRET" ``` -------------------------------- ### TypeScript Local-First Auth Setup Source: https://github.com/garden-co/jazz/blob/main/docs/content/docs/getting-started/client-setup.mdx Basic TypeScript setup for local-first authentication, demonstrating the initialization of the Jazz client with an `appId`. ```ts import { createJazzClient, type AuthSecretStore, } from "jazz-tools/core"; const client = createJazzClient({ appId: "YOUR_APP_ID", // secret: "YOUR_SECRET", // Optional: if you have a secret // serverUrl: "YOUR_SERVER_URL", // Optional: for sync }); // ... use client.login() and client.signOut() ... ``` -------------------------------- ### Install Dependencies and Build Project Source: https://github.com/garden-co/jazz/blob/main/README.md Commands to install project dependencies, ensure Rust toolchain, build the project, and run tests. ```sh pnpm install pnpm run ensure:rust-toolchain pnpm build pnpm test ``` -------------------------------- ### Install sccache Source: https://github.com/garden-co/jazz/blob/main/dev/CONTRIBUTING.md Install sccache using cargo or brew. This tool caches compiler invocations to speed up builds. ```sh cargo install sccache # or: brew install sccache ``` -------------------------------- ### Setup Jazz Client for Vue Source: https://github.com/garden-co/jazz/blob/main/docs/content/docs/install/client.mdx Basic setup for integrating Jazz client into a Vue application. This includes initializing the JazzProvider. ```vue ``` -------------------------------- ### Install MCP Server for AI Assistants Source: https://github.com/garden-co/jazz/blob/main/packages/jazz-tools/bin/docs-index.txt Install the jazz-docs MCP server for your AI assistant. This command adds the jazz-docs tool, which provides access to Jazz documentation. Restart your assistant after running the command. ```bash #!/usr/bin/env bash claude mcp add jazz-docs -- npx jazz-tools@alpha mcp gemini mcp add jazz-docs npx jazz-tools@alpha mcp codex mcp add jazz-docs -- npx jazz-tools@alpha mcp opencode mcp add jazz-docs -- npx jazz-tools@alpha mcp ``` ```bash #!/usr/bin/env bash claude mcp add jazz-docs -- npx jazz-tools@alpha mcp gemini mcp add jazz-docs npx jazz-tools@alpha mcp codex mcp add jazz-docs -- npx jazz-tools@alpha mcp opencode mcp add jazz-docs -- npx jazz-tools@alpha mcp ``` ```bash #!/usr/bin/env bash claude mcp add jazz-docs -- npx jazz-tools@alpha mcp gemini mcp add jazz-docs npx jazz-tools@alpha mcp codex mcp add jazz-docs -- npx jazz-tools@alpha mcp opencode mcp add jazz-docs -- npx jazz-tools@alpha mcp ``` ```bash #!/usr/bin/env bash claude mcp add jazz-docs -- npx jazz-tools@alpha mcp gemini mcp add jazz-docs npx jazz-tools@alpha mcp codex mcp add jazz-docs -- npx jazz-tools@alpha mcp opencode mcp add jazz-docs -- npx jazz-tools@alpha mcp ``` -------------------------------- ### Start Vite App Source: https://github.com/garden-co/jazz/blob/main/examples/auth-simple-chat/README.md Starts the Vite development server for the React application. Access the app at http://127.0.0.1:5173. ```bash pnpm dev ``` -------------------------------- ### Start Local Observability Stack Source: https://github.com/garden-co/jazz/blob/main/dev/observability/README.md Starts the local observability stack using Docker Compose. Ensure you are in the 'dev/observability' directory. ```sh cd dev/observability docker compose up -d ``` -------------------------------- ### Install Jazz Tools (React, Vue, Svelte, TypeScript) Source: https://github.com/garden-co/jazz/blob/main/docs/content/docs/install/client.mdx Install the Jazz client tools using pnpm. This command is applicable for React, Vue, Svelte, and plain TypeScript projects. ```bash pnpm add jazz-tools@alpha ``` -------------------------------- ### Vue Client Setup with BrowserAuthSecretStore Source: https://github.com/garden-co/jazz/blob/main/packages/jazz-tools/bin/docs-index.txt Initialize a Jazz client in a Vue application using `BrowserAuthSecretStore` to manage the secret and `createJazzClient` for setup. Requires `JazzProvider` for context. ```vue import { createJazzClient, JazzProvider } from "jazz-tools/vue"; import { BrowserAuthSecretStore } from "jazz-tools"; import TodoList from "./TodoList.vue"; const secret = await BrowserAuthSecretStore.getOrCreateSecret(); const client = await createJazzClient({ appId: "", secret, }); ``` -------------------------------- ### Run create-jazz-e2e for a Single Starter Source: https://github.com/garden-co/jazz/blob/main/packages/create-jazz-e2e/README.md Execute the end-to-end harness for a specific starter, like 'next-localfirst'. Ensure workspace core packages are built first. ```bash pnpm build:core pnpm --filter create-jazz-e2e exec tsx src/cli.ts next-localfirst ``` -------------------------------- ### Run create-jazz-e2e for All Starters Source: https://github.com/garden-co/jazz/blob/main/packages/create-jazz-e2e/README.md Execute the end-to-end harness sequentially for all available starters. ```bash pnpm --filter create-jazz-e2e exec tsx src/cli.ts --all ``` -------------------------------- ### Get Session in Vue Setup Source: https://github.com/garden-co/jazz/blob/main/packages/jazz-tools/bin/docs-index.txt Retrieve the current user's session using `useSession()` within a Vue ` ``` -------------------------------- ### Running the Rust Todo Server Source: https://github.com/garden-co/jazz/blob/main/examples/todo-server-rs/README.md Instructions to set up and run the Rust backend. This involves starting the Jazz sync server and then running the Rust application. ```bash # 1. Create an app and start the Jazz sync server jazz-tools create app --name todo-app jazz-tools server --port 1625 # 2. Run the Rust backend cargo run -p todo-server ``` -------------------------------- ### Set up basic permissions Source: https://github.com/garden-co/jazz/blob/main/packages/jazz-tools/bin/docs-index.txt Configure permissions to allow all read, insert, update, and delete operations on the todos table for the quickstart. ```typescript policy.todos.allowRead.always(); policy.todos.allowInsert.always(); policy.todos.allowUpdate.always(); policy.todos.allowDelete.always(); }); ``` -------------------------------- ### Run Locally with pnpm Source: https://github.com/garden-co/jazz/blob/main/examples/cloudflare-worker-runtime-ts/README.md Execute the Cloudflare Worker example locally using pnpm. This command starts the development server for the `cloudflare-worker-runtime-ts` package. ```bash pnpm --filter cloudflare-worker-runtime-ts dev ``` -------------------------------- ### Svelte Client Setup with BrowserAuthSecretStore Source: https://github.com/garden-co/jazz/blob/main/packages/jazz-tools/bin/docs-index.txt Set up a Jazz client in a Svelte application using `BrowserAuthSecretStore` to get or create a secret, and `createJazzClient` for client initialization. Uses `JazzSvelteProvider`. ```svelte import { createJazzClient, JazzSvelteProvider, BrowserAuthSecretStore, } from 'jazz-tools/svelte'; import TodoList from './TodoList.svelte'; const client = BrowserAuthSecretStore.getOrCreateSecret().then( (secret) => createJazzClient({ appId: '', secret }) ); ``` -------------------------------- ### Fetch Specific Jazz API Page Source: https://github.com/garden-co/jazz/blob/main/starters/next-hybrid/AGENTS.md Append '.mdx' to a page path obtained from the index to fetch the specific documentation page. For example, to get documentation on defining tables. ```bash https://jazz.tools/docs/schemas/defining-tables.mdx ``` -------------------------------- ### Run Development Server Source: https://github.com/garden-co/jazz/blob/main/docs/README.md Commands to start the Next.js development server using npm, pnpm, or yarn. ```bash npm run dev # or pnpm dev # or yarn dev ``` -------------------------------- ### Managing Transactions with Begin/Rollback Source: https://github.com/garden-co/jazz/blob/main/docs/content/docs/writing/writing-data.mdx Demonstrates starting a transaction using `beginTransaction` and ensuring it is rolled back in `afterEach` to prevent test interference. Includes an example of inserting a task within the transaction. ```typescript let transaction: DbTransaction; beforeEach(() => { transaction = db.beginTransaction(); }); afterEach(() => { // Writes performed in tests will be rolled back at the end, // preventing tests from interfering with each other transaction.rollback(); }); it("tasks have a title", () => { const task = transaction.insert(app.todos, { title: "Test task", done: false }); expect(task.title).toEqual("Test task"); }); ``` -------------------------------- ### Recursive Query with gather and hopTo (TypeScript) Source: https://github.com/garden-co/jazz/blob/main/packages/jazz-tools/bin/docs-index.txt Use gather to walk the graph recursively and collect all reachable rows. This example starts from incomplete todos and follows the parent relation up to 10 levels deep. ```typescript return app.todos.gather({ start: { done: false }, step: ({ current }) => app.todos.where({ parentId: current }).hopTo("parent"), maxDepth: 10, }); } ``` -------------------------------- ### Normal App Workflow Example Source: https://github.com/garden-co/jazz/blob/main/specs/status-quo/ts_client.md Demonstrates a typical application workflow including database connection, fetching all records, subscribing to changes, and inserting a new record. ```typescript const db = await createDb(config); const todos = await db.all(app.todos.where({ done: false })); const unsubscribe = db.subscribeAll(app.todos, ({ all }) => { console.log(all); }); await db.insert(app.todos, { title: "Ship docs", done: false }); ``` -------------------------------- ### Programmatic Secret Creation and DB Initialization Source: https://github.com/garden-co/jazz/blob/main/packages/jazz-tools/bin/docs-index.txt This TypeScript snippet demonstrates how to programmatically get or create an authentication secret using `BrowserAuthSecretStore` and then use it to create a database instance with `createDb`. This is useful for direct database setup without a UI framework. ```ts const secret = await BrowserAuthSecretStore.getOrCreateSecret({ appId: "my-app" }); return createDb({ appId: "my-app", secret, }); } ``` -------------------------------- ### Run create-jazz-e2e and Keep Temp Directory on Failure Source: https://github.com/garden-co/jazz/blob/main/packages/create-jazz-e2e/README.md Execute the end-to-end harness for a specific starter, preserving the scaffolded temporary directory after a failure for inspection. ```bash pnpm --filter create-jazz-e2e exec tsx src/cli.ts next-localfirst --keep ``` -------------------------------- ### Set jazz-wasm-tracing as Global Default Subscriber Source: https://github.com/garden-co/jazz/blob/main/crates/wasm-tracing/README.md This snippet shows how to set `wasm_tracing` as the global default tracing subscriber in your `wasm_bindgen(start)` function. This is the simplest way to set up the tracing functionality out of the box. It also includes the setup for `console_error_panic_hook` for better error reporting. ```rust #[wasm_bindgen(start)] pub fn start() -> Result<(), JsValue> { // print pretty errors in wasm https://github.com/rustwasm/console_error_panic_hook // This is not needed for tracing_wasm to work, but it is a common tool for getting proper error line numbers for panics. console_error_panic_hook::set_once(); // Add this line: wasm_tracing::set_as_global_default(); Ok(()) } ``` -------------------------------- ### Local-First Authentication Setup (Svelte) Source: https://github.com/garden-co/jazz/blob/main/docs/content/docs/auth/local-first-auth.mdx Integrate local-first authentication into a Svelte application. This approach uses a locally managed secret for authentication, allowing users to start using the app immediately without server-side registration. The `LocalFirstAuth` store from `jazz-tools/svelte` also provides `login` and `signOut` functions. ```svelte ``` -------------------------------- ### Start Local Development Server Source: https://github.com/garden-co/jazz/blob/main/specs/todo/b_launch/cli_and_dev_workflow.md Use this command to initiate the full local development loop. It watches schema files, regenerates the TypeScript client, assists with migrations, and manages the local sync server. ```bash pnpx jazz dev ``` -------------------------------- ### Install MCP Server for Claude Code Source: https://github.com/garden-co/jazz/blob/main/docs/content/docs/reference/mcp.mdx Install the jazz-tools package to enable the MCP server for Claude Code. Restart your assistant after installation. ```bash pnpm dlx jazz-tools mcp ``` -------------------------------- ### Create TypeScript Project Source: https://github.com/garden-co/jazz/blob/main/docs/content/docs/install/client.mdx Use these commands to set up a basic TypeScript project directory and install Vite. ```bash mkdir my-jazz-app && cd my-jazz-app pnpm init pnpm add vite typescript ``` -------------------------------- ### Add Todo in Vue Setup Source: https://github.com/garden-co/jazz/blob/main/packages/jazz-tools/bin/docs-index.txt Obtain a database handle using `useDb()` within a Vue `