Generating a Development Token
- PowerSync Cloud
- Self-Hosted
- In the PowerSync Dashboard, select your project and instance
- Go to the Client Auth view
- Check the Development tokens setting and save your changes
- Click the Connect button in the top bar
- Enter a user ID:
- If your data isn’t filtered by user (same data syncs to all users), you can use any value (e.g.,
test-user).
- If your data isn’t filtered by user (same data syncs to all users), you can use any value (e.g.,
- If your data is filtered by , use a user ID that matches a user in your database. PowerSync uses this (e.g.
auth.user_id()in Sync Streams) to determine what to sync.
- Click Generate Token and copy the token
Development tokens expire after 12 hours.
Adding Claims
If your Sync Streams read claims from the token besides the user ID, such asauth.parameter('tenant_id'), add those claims to the development token. Without them, a client that connects with the token can sync different data than the user’s own devices.
- On PowerSync Cloud, add them under Auth Parameters in Sync Test. Sync Test lists the claims that your Sync Streams read, and you can type in any other claim.
- With the PowerSync CLI, add a
--claimflag for each claim. This works for PowerSync Cloud and self-hosted instances.
tenant_id claim and a roles claim.
42 becomes a number and ["admin"] becomes an array. If your Sync Streams compare the claim with a text column, put the value in double quotes, like --claim=code='"42"'.
A development token always sets sub, iss, aud, iat and exp itself, so you cannot add these as claims. The user ID, or --subject in the CLI, becomes sub.
Usage
Using with Your Application
While you build your app, use a development token to connect it to PowerSync. Return the token fromresolveCredentials() in your authenticator. The setup guide shows the full connect call for each SDK.