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!
- New Blackholio tutorial which has feature parity with Unity. Try it now: https://spacetimedb.com/docs/unreal
- New API reference: https://spacetimedb.com/docs/unreal/reference
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
execute_plan
: don't build temporary vec of rows by @Centril in #2918- smoktests: Wait for batched consensus by @kim in #3010
- Addresses #2969 by @cloutiertyler in #2980
- Dont generate connection_ids in the rust client. by @jsdt in #3004
- CI - Set Unity testsuite timeout to 30m by @bfops in #3015
- CI - Make new CI checks run in merge queue by @bfops in #3016
- Update DLLs to 1.3.0 by @bfops in #3018
- CI - Remove
bots please
by @bfops in #3102 - Blackholio - Hide generated files from diffs by @bfops in #3119
- Implement reduced coupling between SpacetimeDBClient.cs and Table.cs by @rekhoff in #3122
- Docs - Fix incorrect reference to Rust client SDK by @bfops in #3124
- TypeScript - Bump version to 1.3.1 for release by @bfops in #3123
- Add repo migration notice workflows by @bfops in #3127
- Update README.md by @GageHowe in #1703
- refactor(sdk): improve the log message source line reference by @ResuBaka in #2924
- commitlog: Provide folding over a range of tx offsets by @kim in #3129
- Blackholio - Logging back in and resuming gameplay by @jdetter in #2990
- Drop log for already-compressed snapshot to debug by @gefjon in #3131
- Add "How to compile" section to Rust quickstart by @bfops in #3136
- Blackholio - Enable more tests by @bfops in #3135
- V8: Use clearer lifetime names by @Centril in #3009
- Update outdated the demo Blackholio source url by @Rot4tion in #3150
- C#/Unity SDK - Add some developer docs by @bfops in #3140
- Typescript SDK: Fix to actually use the passed onclose function by @natebot13 in #3152
- V8: Ser/de finishing touches by @Centril in #3153
- Update all licenses by @bfops in #3002
- Fix module hotswapping for connected clients by @kim in #3159
- V8: Define and test
call_describe_module
by @Centril in #3161 - Increase default
incoming_queue_length
limit, log warning when a client violates it by @gefjon in #3171 - fix incoming message queue length metric by @joshua-spacetime in #3172
- TimeSpan-Style TimeDuration Constructors in C# Bindings by @wes-sleeman in #2778
- Added RLS to llms.txt by @bfops in #3134
- Add workflow preview diagram in index by @bfops in #3139
- Fix issue with scheduled reducers being executed twice after module reload by @Shubham8287 in #3179
- Reduce
tools/publish-crates.sh
to only publishbindings
andsdk
by @bfops in #3180 - Enable adding columns in auto migrations in
schema
crate by @kazimuth in #2956 tools/publish-crates.sh
is more flexible for crate paths by @bfops in #3185- Automigration pretty print by @Shubham8287 in #3121
- Move
crates/sdk
tosdks/rust
by @bfops in #3181 - Remove some dead code by @Centril in #3189
- Pretty print: sort hashmap iters by @Shubham8287 in #3188
- Disable column type changes in an automigration by @joshua-spacetime in #3178
- Refactor and extract
call_reducer
andupdate_database
machinery for reuse by V8 by @Centril in #3190 - CI - Fix caching in C#/Unity testsuite by @bfops in #3194
alter_table_row_type
: write changes tost_column
by @Centril in #3196- Smoketests can run against remote servers by @bfops in #3012
- Add a RemoteQuery regression test to C# SDK by @rekhoff in #3163
- Fix remaining LICENSE files by @bfops in #3193
- Fix adding enum variants by @Centril in #3200
- Uncommented out 'delete by index' test code by @rekhoff in #3156
- Updated C# quickstart-chat to pattern match variable assignment by @rekhoff in #3173
- Fix fields named 'read' by @kazimuth in #2525
- Sort columns in
st_column_changed
before automigrating. by @gefjon in #3203 - Smoke test for Rust quickstart-chat app #2100 by @mamcx in #3155
- Version upgrade to 1.3.2 by @jdetter in #3207
- Improve error reporting for invalid column-type-changing automigrations by @gefjon in #3202
- V8: Add
call_call_reducer
incl with stack traces + wire update_database by @Centril in #3212 - CI - License checks by @bfops in #3197
- Separate out TypeScript module library from the SDK by @cloutiertyler in #3182
- Unifies TypeScript packages and command names by @cloutiertyler in #3195
- Tidy up CLI reference generation flow by @bfops in #3226
- Fix the smoke test so it take the server URL from the config.toml by @mamcx in #3227
- utilities for archiving snapshots by @joshua-spacetime in #3224
- Remove version number and git commit from all but one file in codegen by @cloutiertyler in #3216
- V8: wire more of
call_reducer
by @Centril in #3225 - Removed // @ts-ignore directive from generated files and fixes associated errors by @cloutiertyler in #3228
tools/upgrade-version
works properly on Windows by @bfops in #3232- Dont use sentinel ids for system tables. by @jsdt in #3209
- Adds TypeBuilders and ColumnBuilders for specifying the schema of a TypeScript module by @cloutiertyler in #3208
- Confirmed reads by @kim in #3133
- Endpoint for pretty print migration plan by @Shubham8287 in #3137
- Support for the PG wire protocol by @mamcx in #2702
- rust:
default
macro by @Shubham8287 in #3177 - Added some additional typing to the TS SDK by @cloutiertyler in #3245
- core: Remove
init_maybe_update_module_host
from host controller by @kim in #3246 - smoketests: Smoketest enable replication for existing database by @kim in #3138
- Add channel params to commitlog compressor by @joshua-spacetime in #3254
- Store client credentials in a new system table by @jsdt in #2983
- Recombining circles doesn't work by @JasonAtClockwork in #3234
- Remove smoke test check for SSL support, let the defaults works by @mamcx in #3259
- Refactors TypeScript into a single
spacetimedb
package by @cloutiertyler in #3248 - Added the Unreal SDK work for codegen, testing, and the plugin by @JasonAtClockwork in #3223
- Implements React Hooks for the TypeScript SDK by @cloutiertyler in #3255
- Add Unreal Blackholio by @JasonAtClockwork in #3260
- Unreal Blackholio Tutorial Documentation by @JasonAtClockwork in #3253
New Contributors
- @GageHowe made their first contribution in #1703
- @Rot4tion made their first contribution in #3150
- @natebot13 made their first contribution in #3152
- @wes-sleeman made their first contribution in #2778
- @JasonAtClockwork made their first contribution in #3234
Full Changelog: v1.3.2...v1.4.0