Install and sign in
Install @dasterhq/daster, connect the daster command to a project and choose the keys the SDK needs.
Last updated
Install
Add the SDK to your app:
npm install @dasterhq/dasterInstall the daster command on your machine, or run it once with npx:
npm install --global @dasterhq/daster
npx @dasterhq/daster --versionSign in with the command
The command does not use your password or a project key. It asks DASTER for a connection to one project and environment, and you approve it in the Dashboard.
- Run
daster login. Add--writeif the command should be allowed to make changes, such as deploys. Add--opento open the address in your browser. - The command prints an address under "Approve this connection in DASTER (choose project and environment)". Open it while signed in to DASTER.
- On the consent page, choose the Organization, Project and Environment. Reading the project, websites, databases and logs is always included. If you ran
login --write, tick Upload, deploy websites and connect databases to allow changes. - Choose Allow.
The browser returns to a short-lived listener that the command opens on 127.0.0.1 on your own machine, and the command prints:
Connected "default" to project <project id> / environment <environment id> with daster:read, daster:write.The command waits up to 10 minutes for you to approve. Choosing Deny ends it with "The connection was denied in DASTER."
An environment other than Development needs one more confirmation and a sign-in within the last 10 minutes. Only organization Owners and Admins can allow changes outside Development, and each change there still waits for your approval.
Several projects
Each connection is a profile. Without --profile the name is default. Use one profile per project or environment:
daster login --profile shop-dev --write
daster listdaster list prints one line per profile: its name, the DASTER address, the project and the scopes.
Where the tokens are kept
The command stores its tokens in connections.json in its config folder:
| Setting | Folder |
|---|---|
DASTER_CONFIG_DIR | That folder, when it is set |
XDG_CONFIG_HOME | $XDG_CONFIG_HOME/daster |
| Neither | ~/.config/daster |
The file is readable only by you (mode 0600, in a 0700 folder). An access token lasts 10 minutes and the command renews it by itself. The refresh token lasts 30 days and changes at every renewal. If an old refresh token is used again, DASTER revokes the whole connection; run daster login again.
Sign out
daster logout --profile shop-devThis revokes the connection in DASTER and removes the profile from the file. If DASTER cannot be reached, the profile is still removed, and you can disconnect it in the Dashboard under Developer access › Connections.
Keys for the SDK
The SDK uses project keys, not the command's connection. Copy them from Project settings › Connection (see Project keys).
| Key | Client | Where it may run |
|---|---|---|
Browser key daster_pk_… | createProductClient | Browser and mobile code. Your row-level security applies |
Server key daster_sk_… | createServiceClient | Your server only. It bypasses row-level security |
App email key daster_sk_… | createCommunicationsClient | Your server only |
The server key reaches the database, storage and realtime, and it can also send and read App email. For email you can instead create a narrower key under App email › Settings (see App email). Older daster_comm_… keys keep working with the communications client.
The SDK reads no environment variables of its own. Pass the project ID and keys as options, for example from process.env. createServiceClient and createCommunicationsClient refuse to start in a browser page, so a server key is not bundled into a site by mistake.
Warning: Never put a server key or an App email key in browser code, a mobile app or a Git repository.