Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

cloutiertyler
Copy link
Contributor

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');

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

TODO: I am not through testing yet.

@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
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 on lines +80 to +81
'Could not find SpacetimeDB client! Did you forget to add a' +
'`SpacetimeDBProvider`? `useTable` must be used in the React component tree' +
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
'Could not find SpacetimeDB client! Did you forget to add a' +
'`SpacetimeDBProvider`? `useTable` must be used in the React component tree' +
'Could not find SpacetimeDB client! Did you forget to add a ' +
'`SpacetimeDBProvider`? `useTable` must be used in the React component tree' +

I think it's lacking a space between the two concatenated string "aSpacetimeDBProvider"

Comment on lines +27 to +28
'eyJhbGciOiJSUzI1NiJ9.eyJzdWIiOiIwMUpCQTBYRzRESFpIWUdQQk5GRFk5RDQ2SiIsImlzcyI6Imh0dHBzOi8vYXV0aC5zdGFnaW5nLnNwYWNldGltZWRiLmNvbSIsImlhdCI6MTczMDgwODUwNSwiZXhwIjoxNzkzODgwNTA1fQ.kGM4HGX0c0twL8NJoSQowzSZa8dc2Ogc-fsvaDK7otUrcdGFsZ3KsNON2eNkFh73FER0hl55_eJStr2tgoPwfTyl_v_TqkY45iUOUlLmHfB-X42cMzpE7PXbR_PKYcp-P-Wa4jGtVl4oF7CvdGKxlhIYEk3e0ElQlA9ThnZN4IEciYV0vwAXGqbaO9SOG8jbrmlmfN7oKgl02EgpodEAHTrnB2mD1qf1YyOw7_9n_EkxJxWLkJf9-nFCVRrbfSLqSJBeE6OKNAu2VLLYrSFE7GkVXNCFVugoCDM2oVJogX75AgzWimrp75QRmLsXbvB-YvvRkQ8Gfb2RZnqCj9kiYg'
);
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this token meant to be here? It's a valid token

{
  "sub": "01JBA0XG4DHZHYGPBNFDY9D46J",
  "iss": "https://auth.staging.spacetimedb.com",
  "iat": 1730808505,
  "exp": 1793880505
}

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