Skip to content

Implements React Hooks for the TypeScript SDK#3255

Merged
cloutiertyler merged 5 commits into
masterfrom
tyler/react-hooks-2
Sep 22, 2025
Merged

Implements React Hooks for the TypeScript SDK#3255
cloutiertyler merged 5 commits into
masterfrom
tyler/react-hooks-2

Conversation

@cloutiertyler
Copy link
Copy Markdown
Contributor

@cloutiertyler cloutiertyler commented Sep 18, 2025

Description of Changes

This adds react as an optional peer dependency. If the TypeScript SDK is imported into a library that uses React (of the appropriate version) then they will have access to two new React hooks:

useSpacetimeDB<DbConnection>();
useTable<DbConnection, MyTable>('my_table');

This PR also updates the TypeScript quickstart-chat tutorial in the docs to use the new React hooks. I will split that tutorial into separate React and TypeScript tutorials in a future PR.

API and ABI breaking changes

This is a purely additive change to the SDK

Expected complexity level and risk

2 because it changes how the SDK is built a bit. Namely it makes the spacetimedb library an external dependency.

Testing

  • Tested the quickstart-chat tutorial app and confirmed features to be working.

@cloutiertyler cloutiertyler changed the title Tyler/react hooks 2 Implements React Hooks for the TypeScript SDK Sep 18, 2025
@cloutiertyler cloutiertyler changed the base branch from master to tyler/react-hooks September 18, 2025 21:17
Copy link
Copy Markdown
Contributor

@JulienLavocat JulienLavocat left a comment

Choose a reason for hiding this comment

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

LGTM, I've left two comments

Comment thread crates/bindings-typescript/src/react/useTable.ts Outdated
Comment thread crates/bindings-typescript/test-app/src/main.tsx
cloutiertyler and others added 3 commits September 21, 2025 18:03
This reverts commit 3bb574f.
Co-authored-by: Julien Lavocat <JulienLavocat@users.noreply.github.com>
Signed-off-by: Tyler Cloutier <cloutiertyler@users.noreply.github.com>
@cloutiertyler cloutiertyler changed the base branch from tyler/react-hooks to master September 21, 2025 22:03
@cloutiertyler cloutiertyler marked this pull request as ready for review September 22, 2025 13:31
@cloutiertyler cloutiertyler added this pull request to the merge queue Sep 22, 2025
Merged via the queue into master with commit 34d8cd4 Sep 22, 2025
28 of 29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants