5 Commits

Author SHA1 Message Date
bradleyshep c14c8d15b0 TS quickstart template fixes (nextjs + nodejs) (#4380)
# Description of Changes

- Node.js: Use esbuild instead of tsx 
- Node.js: Remove interactive CLI since it doesn't work with `spacetime
dev`
- Next.js: Fix onError callback to use single argument (ctx) and use
ctx.event for the error.
- Next.js: Replace lint-disable comment with `_connection` for the
unused variable.
- Updated quickstart docs to use proper `withDatabaseName`

# API and ABI breaking changes

None.

# Expected complexity level and risk

**Complexity: 1–2.** Small tooling, type, and lint tweaks. Low risk.

# Testing

- [ ] Build affected templates (e.g. `pnpm build` in nextjs-ts).
- [ ] Lint passes.
2026-02-22 11:05:56 +00:00
clockwork-tien 029e7c1e40 fix: Additional fixes for templates (#4372)
# Description of Changes
- Add back `{ public: true }` to tables, update `module_bindings`
accordingly
- Add missing templates to `pnpm-workspace.yaml`

<!-- Please describe your change, mention any related tickets, and so on
here. -->

# API and ABI breaking changes

<!-- If this is an API or ABI breaking change, please apply the
corresponding GitHub label. -->

# Expected complexity level and risk

<!--
How complicated do you think these changes are? Grade on a scale from 1
to 5,
where 1 is a trivial change, and 5 is a deep-reaching and complex
change.

This complexity rating applies not only to the complexity apparent in
the diff,
but also to its interactions with existing and future code.

If you answered more than a 2, explain what is complex about the PR,
and what other components it interacts with in potentially concerning
ways. -->

# Testing

<!-- Describe any testing you've done, and any testing you'd like your
reviewers to do,
so that you're confident that all the changes work as expected! -->

- [ ] <!-- maybe a test you want to do -->
- [ ] <!-- maybe a test you want a reviewer to do, so they can check it
off when they're satisfied. -->

---------

Co-authored-by: bradleyshep <148254416+bradleyshep@users.noreply.github.com>
2026-02-20 21:15:42 +00:00
bradleyshep cea601ffa4 Fix various TS templates (#4360)
# Description of Changes

Fix `withModuleName` -> `withDatabaseName` in server-side code across
multiple TypeScript templates. The 2.0 SDK renamed this method, but
several templates still used the old 1.x API name, causing a runtime
error (`DbConnection.builder(...).withUri(...).withModuleName is not a
function`).

**Files changed:**
- `templates/nuxt-ts/server/api/people.get.ts`
- `templates/remix-ts/app/lib/spacetimedb.server.ts`
- `templates/nextjs-ts/lib/spacetimedb-server.ts`
- `templates/nodejs-ts/src/main.ts`
- `templates/deno-ts/src/main.ts`
- `templates/keynote-2/src/connectors/spacetimedb.ts`

# API and ABI breaking changes

None. This aligns templates with the existing 2.0 SDK API.

# Expected complexity level and risk

1 — Trivial string replacement across template files. No logic changes.

# Testing

- [ ] Run `spacetime dev --template nuxt-ts` and verify the Nuxt SSR
server API (`/api/people`) connects without `withModuleName is not a
function` error
- [ ] Run `spacetime dev --template nextjs-ts` and verify the
server-side SpacetimeDB connection works
- [ ] Run `spacetime dev --template remix-ts` and verify the server-side
SpacetimeDB connection works
2026-02-20 15:05:45 +00:00
Noa 098afaf1a5 [TS] Improve autogen autocompletion and typing (#4309)
# Description of Changes

All types are now defined and exported in `module_bindings/types.ts`,
meanings there's only one module you need to import from to access
types.

# Expected complexity level and risk

2

# Testing

n/a, no change in behavior.
2026-02-19 06:17:02 +00:00
bradleyshep 0ed052eb0d Quickstart nodejs (#4112)
# Description of Changes

Adds a Node.js quickstart template and documentation for SpacetimeDB.

## Template (`templates/nodejs-ts/`)
- SpacetimeDB module with TypeScript (`spacetimedb/src/index.ts`)
- Node.js client with interactive CLI (`src/main.ts`)
- File-based token persistence (`.spacetimedb-token`) instead of
localStorage
- Table change callbacks (`onInsert`, `onDelete`)
- Graceful shutdown handlers for `SIGINT`/`SIGTERM`
- Pre-generated module bindings in `src/module_bindings/`

## Documentation
(`docs/docs/00100-intro/00200-quickstarts/00300-nodejs.md`)
- Step-by-step quickstart guide following existing pattern
- Covers project creation with `spacetime dev --template nodejs-ts`
- Explains project structure and client code
- Documents interactive CLI commands (`list`, `hello`, `<name>`)
- Covers Node.js-specific considerations (WebSocket support, token
storage)
- Documents environment variable configuration (`SPACETIMEDB_HOST`,
`SPACETIMEDB_DB_NAME`)

## Consistency
- Environment variables follow the same `HOST`/`DB_NAME` naming
convention as other quickstarts
- Documentation structure mirrors React and Next.js quickstarts

# API and ABI breaking changes

None.

# Expected complexity level and risk

1 - Additive change only. New template and documentation, no
modifications to existing functionality.

# Testing

- [ ] Run `spacetime dev --template nodejs-ts` and verify project
initializes
- [ ] Run `npm run dev` and verify connection to SpacetimeDB
- [ ] Test adding a person by typing a name
- [ ] Test `list` command shows all people
- [ ] Test `hello` command calls reducer (check server logs)
- [ ] Verify token persistence works across restarts
- [ ] Test graceful shutdown with Ctrl+C
- [ ] Check documentation renders correctly
2026-02-11 16:15:50 +00:00