Fixes #4582 Templates created via `spacetime init` were missing `.gitignore` files, causing build artifacts like `node_modules`, `target/`, `bin/`, `obj/`, `dist/`, `.next/`, etc. to show up in git diffs when users initialize a project inside a git repository. Adds `.gitignore` files to the 15 templates that were missing one: | Template | Ignores | |----------|---------| | Node/TS (`basic-ts`, `browser-ts`, `bun-ts`, `chat-react-ts`, `deno-ts`, `nodejs-ts`, `react-ts`, `vue-ts`) | `node_modules`, `dist`, `*.log` | | Next.js (`nextjs-ts`) | `node_modules`, `.next`, `out`, `dist`, `*.log` | | Svelte (`svelte-ts`) | `node_modules`, `dist`, `.svelte-kit`, `*.log` | | Rust (`basic-rs`, `chat-console-rs`) | `target` | | C# (`basic-cs`, `chat-console-cs`) | `bin`, `obj` | | C++ (`basic-cpp`) | `target`, `build` | All files also include `spacetime.local.json` and `.DS_Store`. The 5 templates that already had `.gitignore` files (`angular-ts`, `keynote-2`, `nuxt-ts`, `remix-ts`, `tanstack-ts`) are left unchanged. Co-authored-by: clockwork-labs-bot <clockwork-labs-bot@users.noreply.github.com>
Get a SpacetimeDB Svelte app running in under 5 minutes.
Prerequisites
- Node.js 18+ installed
- SpacetimeDB CLI installed
Install the SpacetimeDB CLI before continuing.
Create your project
Run the spacetime dev command to create a new project with a SpacetimeDB module and Svelte client.
This will start the local SpacetimeDB server, publish your module, generate TypeScript bindings, and start the Svelte development server.
spacetime dev --template svelte-ts
Open your app
Navigate to http://localhost:5173 to see your app running.
The template includes a basic Svelte app connected to SpacetimeDB.
Explore the project structure
Your project contains both server and client code.
Edit spacetimedb/src/index.ts to add tables and reducers. Edit src/App.svelte to build your UI.
my-spacetime-app/
├── spacetimedb/ # Your SpacetimeDB module
│ └── src/
│ └── index.ts # Server-side logic
├── src/ # Svelte frontend
│ ├── App.svelte
│ └── module_bindings/ # Auto-generated types
└── package.json
Understand tables and reducers
Open spacetimedb/src/index.ts to see the module code. The template includes a person table and two reducers: add to insert a person, and sayHello to greet everyone.
Tables store your data. Reducers are functions that modify data — they're the only way to write to the database.
import { schema, table, t } from 'spacetimedb/server';
const spacetimedb = schema({
person: table(
{ public: true },
{
name: t.string(),
}
),
});
export default spacetimedb;
export const add = spacetimedb.reducer(
{ name: t.string() },
(ctx, { name }) => {
ctx.db.person.insert({ name });
}
);
export const sayHello = spacetimedb.reducer(ctx => {
for (const person of ctx.db.person.iter()) {
console.info(`Hello, ${person.name}!`);
}
console.info('Hello, World!');
});
Test with the CLI
Open a new terminal and navigate to your project directory. Then use the SpacetimeDB CLI to call reducers and query your data directly.
cd my-spacetime-app
# Call the add reducer to insert a person
spacetime call add Alice
# Query the person table
spacetime sql "SELECT * FROM person"
name
---------
"Alice"
# Call sayHello to greet everyone
spacetime call say_hello
# View the module logs
spacetime logs
2025-01-13T12:00:00.000000Z INFO: Hello, Alice!
2025-01-13T12:00:00.000000Z INFO: Hello, World!
Next steps
- Read the TypeScript SDK Reference for detailed API docs