github clockworklabs/SpacetimeDB v1.4.0
Release v1.4.0

11 hours ago

We have an exciting announcement for you today 🎉🎉🎉 We've been cooking on Unreal Engine and React Hooks for a while now and we're finally ready to release both of them.

Unreal Engine

We know this is one highly requested feature so today we're happy to announce that SpacetimeDB now fully supports Unreal Engine. You can use our Unreal Engine SDK with either C# or Rust SpacetimeDB modules. We have even extended the Blackholio demo to work with the existing modules. So this means we've added Unreal Engine as a client alongside our Unity implementation. You can even connect both a Unity and Unreal Engine Blackholio client to the same module. We know this has been a highly requested feature that the community has been asking for so we're excited to see what everyone builds with it!

If you don't want to do the tutorial and you just want to play around want to try out our Blackholio demo you can find the latest version here: https://github.com/clockworklabs/SpacetimeDB/tree/master/demo/Blackholio

Shoutout to Arvikasoft who we collaborated with for the development of this SDK!

React Hooks 🪝 (Beta)

React hooks for SpacetimeDB are now here! Using SpacetimeDB with React is now much much easier. Just add a SpacetimeDBProvider to your component hierarchy and use the useTable React hook!

// main.tsx
const connectionBuilder = DbConnection.builder()
  .withUri('wss://maincloud.spacetimedb.com')
  .withModuleName('MODULE_NAME');

ReactDOM.createRoot(document.getElementById('root')!).render(
  <React.StrictMode>
    <SpacetimeDBProvider connectionBuilder={connectionBuilder}>
      <App />
    </SpacetimeDBProvider>
  </React.StrictMode>
);

// App.tsx
function App() {
  const conn = useSpacetimeDB<DbConnection>();
  const { rows: messages } = useTable<DbConnection, Message>('message');

  ...
}

SpacetimeDB will magically synchronize your table state with your React client and re-render your UI as it changes. About as simple as it gets!

For added power, add a typed where clause to your useTable hook to filter the rows you want to subscribe to:

const { rows: users } = useTable<DbConnection, User>('user', where(eq('online', true)));

Upgrade Instructions

In order to receive this update you'll first need CLI version 1.4.0. In order to upgrade to the new CLI version you can just run spacetime version upgrade which will automatically upgrade you to the newest version. If you don't have SpacetimeDB installed you'll need to go to https://spacetimedb.com/install .

You can verify that you have the newest version installed by running spacetime version list in your terminal application:

> spacetime version list
1.4.0 (current)

Then you'll need to update your SpacetimeDB SDK version in your package.json file. Before this update you would have had something like this:

  "dependencies": {
    "@clockworklabs/spacetimedb-sdk": "^1.3.0",
    ...
  },

Now our new package looks like this:

  "dependencies": {
    "spacetimedb": "^1.4.0",
    ...
  },

If you are at all confused you can just look at our Typescript quickstart which has instructions on installing the CLI + using the correct package in package.json: https://staging.spacetimedb.com/docs/sdks/typescript/quickstart

React Hooks Example

Here's an example of how this works:

some example code of using react hooks

Confirmed Reads

"Confirmed reads" is a feature which allows you to specify during the connection setup that you only want to hear back about transactions which have already been persisted. This means these transactions will not be lost if the server you are connected to experiences a hardware failure of some sort.

Here is an example of how to enable confirmed reads:

const connectionBuilder = DbConnection.builder()
  .withUri('ws://localhost:3000')
  .withModuleName('quickstart-chat')
  .withConfirmedReads(true)
  .withToken(localStorage.getItem('auth_token') || undefined)
  .onConnect(onConnect)
  .onDisconnect(onDisconnect)
  .onConnectError(onConnectError);

Improvements/Fixes

  • The version number for codegen is now only written to a single file instead of every single generated file. This helps cut down on conflicts when changing SpacetimeDB CLI versions. (#3216)
  • Improve error reporting for invalid column-type-changing automigrations (#3202)
  • Sort columns in st_column_changed before automigrating. (#3203)
  • Fixed not being able to have columns named "read", "write", etc. (#2525)
  • Typescript SDK: Fix to actually use the passed onclose function (#3152)
  • Removed // @ts-ignore directive from generated files and fixes associated errors (#3228)
  • TimeSpan-Style TimeDuration Constructors in C# Bindings (#2778)

What's Changed

New Contributors

Full Changelog: v1.3.2...v1.4.0

Don't miss a new SpacetimeDB release

NewReleases is sending notifications on new releases.