Skip to content

TS Quickstart: Store different auth tokens for different servers/modules#3252

Merged
cloutiertyler merged 1 commit intomasterfrom
jsdt/local-key-per-env
Feb 16, 2026
Merged

TS Quickstart: Store different auth tokens for different servers/modules#3252
cloutiertyler merged 1 commit intomasterfrom
jsdt/local-key-per-env

Conversation

@jsdt
Copy link
Contributor

@jsdt jsdt commented Sep 17, 2025

Description of Changes

In the typescript quickstart example, this includes the server and module name in the local storage variable name that we use for the auth token.

This fixes an otherwise annoying issue people run into if they start running the quickstart locally, then try to run it on maincloud. If they have already run the app with a local server, their browser will store the locally signed token, which will get rejected by maincloud.

Expected complexity level and risk

Testing

I was able to connect to my local quickstart, then change the variables to point to a module on maincloud, and I didn't get any errors.

@jsdt jsdt requested a review from cloutiertyler September 17, 2025 17:47
@bfops bfops added the release-any To be landed in any release window label Sep 22, 2025
Copy link
Contributor

@cloutiertyler cloutiertyler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to update the tutorial as well. We are keeping the quickstart in sync exactly with the tutorial: https://spacetimedb.com/docs/sdks/typescript/quickstart

Use a localStorage key that includes the server URI and database name
(`${HOST}/${DB_NAME}/auth_token`) so that different servers and modules
don't overwrite each other's tokens.

Applied to all templates (react, vue, svelte, nuxt, nextjs, remix,
tanstack, chat-react) and updated docs (tutorial, quickstarts,
connection reference).

Also fixes withModuleName -> withDatabaseName in nuxt, nextjs, remix,
and tanstack templates.

Closes #3252
@clockwork-labs-bot
Copy link
Collaborator

Rebased onto master and expanded the scope — the original file (sdks/typescript/examples/quickstart-chat/src/App.tsx) was deleted during the SDK restructure, so I applied the per-server/database token key pattern to all current templates:

  • Templates updated: react-ts, chat-react-ts, vue-ts, svelte-ts, nuxt-ts, nextjs-ts, remix-ts, tanstack-ts
  • Docs updated: chat tutorial, nuxt quickstart, browser quickstart, connection reference
  • Bonus: Fixed withModuleNamewithDatabaseName in nuxt, nextjs, remix, and tanstack templates

Token key format: ${HOST}/${DB_NAME}/auth_token

Addresses the review feedback about updating the tutorial.

Copy link
Contributor

@cloutiertyler cloutiertyler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This now looks good to me. Although notably, we should update chat-react-ts to not hard code localhost. We should fix that separately.

@cloutiertyler cloutiertyler added this pull request to the merge queue Feb 16, 2026
Merged via the queue into master with commit 08ff1e1 Feb 16, 2026
31 of 32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-2.0 release-any To be landed in any release window

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants