If you are starting a new project, SurrealKit can manage your schema from the very first definition. This guide walks through initialising a project, writing your first schema file, and pushing it to a local SurrealDB instance.
1. Initialise the project
In the root of your repository, run:
This creates a database/ directory with the following layout:
2. Write a schema file
Create a .surql file inside database/schema/. Each file can contain one or more DEFINE statements.
Schema files can be organised by table, by domain, or kept in a single file. SurrealKit applies everything in database/schema/ together.
3. Start a local SurrealDB instance
4. Sync your schema
SurrealKit reads every file in database/schema/, applies the DEFINE statements to the database, and records a content hash for each file in an internal __entity metadata table. Future syncs only re-apply files that have changed.
5. Enable watch mode during development
Pass --watch to keep SurrealKit running and automatically re-sync whenever a schema file changes:
Vite integration
If your project uses Vite, the vite-plugin-surrealkit package runs sync automatically when the dev server starts:
The plugin watches database/schema/**/*.surql and re-syncs on any change, with debouncing to avoid overlapping runs.
Storing connection details
Rather than passing flags on every command, store your local connection details in a .env file at the project root:
With those set, surrealkit sync picks them up automatically.
Next steps
Sync: full reference for all sync options
Sync vs Rollouts: when to move from Sync to the Rollouts workflow