Methods to run your app locally

Ways to run your app locally

Running the server

To run the server locally, you can simply run

npx y-sweet serve

The following command will output a server token to run the client. When running locally, the server token is likely ys://


ys is simply a more secure protocol than http

Running the client

Running the client is as easy as running npm run dev.

But you can also add connection string as a parameter, which will set is an environment variable that you can use by importing it from a lib/config (opens in a new tab) like so:

import {CONNECTION_STRING} from '@/lib/config

In development, the connection string will be specified in the terminal out when you run the server. Usually, its ys://

CONNECTION_STRING="ys://" npm run dev
  • if you don't specify a connection string, it will default to ys://

Specifying a data path

If you don't specify a data path, your data will be ephemeral. When you exit out of a doc and return, your data won't be persisted.

To persist data in a local environment, you can specify a data path like so:

CONNECTION_STRING=ys:// npm run dev ./data

Appending ./data will create a data folder in the root of your app. When user data is created, your data will be stored in the folder that you specified.

Testing multiplayer with y-sweet cloud

You can get a quickstart token on the y-sweet dashboard (opens in a new tab). If you haven't already, you can make an account here (opens in a new tab).

Then, set the connection string to your quickstart token.


You don't need to specify a data path, since your data will now be stored on y-sweet cloud.

y-sweet was created by Jamsocket.