Skip to content

Updated the quickstart to use the new 1.0 API #130

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 28 commits into from
Feb 8, 2025

Conversation

cloutiertyler
Copy link
Contributor

@cloutiertyler cloutiertyler commented Jan 22, 2025

Description of Changes

I've renamed the examples/quickstart directory to examples/quickstart-chat for standardization purposes, and also updated the quickstart example project to be in line with the new 1.0 API and the new quickstart guide in the docs: clockworklabs/spacetime-docs#141.

The directory structure now matches https://github.com/clockworklabs/SpacetimeDB/tree/master/crates/sdk/examples/quickstart-chat identically.

The standard path is <sdk-path>/examples/quickstart-chat.

Note that this differs from what the quickstart tutorial tells you do to. In the tutorial the client is in quickstart-chat/client. Phoebe and I feel that that is okay.

API

This is not an API breaking change.

Requires SpacetimeDB PRs

I do not believe it needs any.

Test

I've added an integration test that verifies that you can connect to SpacetimeDB, change your name and post a message.

Copy link

changeset-bot bot commented Jan 22, 2025

⚠️ No Changeset found

Latest commit: fec9d29

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

pkg-pr-new bot commented Jan 22, 2025

Open in Stackblitz

npm i https://pkg.pr.new/@clockworklabs/spacetimedb-sdk@130

commit: fec9d29

@gefjon
Copy link
Contributor

gefjon commented Jan 24, 2025

Note that I have also moved the implementation of the example from quickstart-chat to quickstart-chat/client. I felt that this would allow for people to have a root directory with client and server. I will note that this is not how https://github.com/clockworklabs/SpacetimeDB/tree/master/crates/sdk/examples/quickstart-chat does it, so I'm open to change it back one level up if that is preferred. We would need to update the tutorial in that case.

I would prefer not to have the server code duplicated in a bunch of different places. I would much prefer that each client SDK repo contain only its client code, with a README linking to the module code in the main SpacetimeDB repository. Failing that, I would accept CI jobs which verify that the module code is line-for-line equal in the two repos. I want to avoid a situation (which we've been in several times in the past) in which each repo defines its own "quickstart-chat" module, with all the versions being different and mutually incompatible.

@cloutiertyler
Copy link
Contributor Author

I would prefer not to have the server code duplicated in a bunch of different places. I would much prefer that each client SDK repo contain only its client code, with a README linking to the module code in the main SpacetimeDB repository. Failing that, I would accept CI jobs which verify that the module code is line-for-line equal in the two repos. I want to avoid a situation (which we've been in several times in the past) in which each repo defines its own "quickstart-chat" module, with all the versions being different and mutually incompatible.

Whoops! Apologies, that was supposed to be removed, not changed. Fixed.

Copy link
Contributor

@jsdt jsdt left a comment

Choose a reason for hiding this comment

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

How do I run this? I tried by running pnpm install then pnpm run dev from the examples/quickstart-chat directory, and when I open it in my browser, I get a blank page and a bunch of errors in the console like the following:

Uncaught TypeError: DBConnection.builder(...).withUri(...).withModuleName(...).withToken is not a function


It is based directly on the plain React + TypeScript + Vite template. You can follow the quickstart guide for how creating this project from scratch at [SpacetimeDB TypeScript Quickstart](https://spacetimedb.com/docs/sdks/typescript/quickstart).

You can follow the instructions for creating your own SpacetimeDB module here: [SpacetimeDB Rust Module Quickstart](https://spacetimedb.com/docs/modules/rust/quickstart). Place the module in the `quickstart-chat/server` directory for compability with this project.
Copy link
Contributor

Choose a reason for hiding this comment

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

This might be more of a comment on the quickstart docs, but I think it would be quicker to get up and running if this linked to the server module code that is ready to be run immediately.

@@ -0,0 +1,60 @@
# SpacetimeDB TypeScript Quickstart Chat
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add the instructions for running this to the readme? As someone who likes to start with being able to run an end-to-end example, then go through the code, it's nice to be able to get clear setup instructions without going through the explanation of how to write the code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I can do this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Steps are added (Zeke added them)

@cloutiertyler
Copy link
Contributor Author

Merging because we decided we don't need the tests for now.

@cloutiertyler cloutiertyler merged commit 333da18 into main Feb 8, 2025
6 of 7 checks passed
@cloutiertyler cloutiertyler deleted the tyler/update-quickstart branch February 8, 2025 02:29
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.

4 participants