# Install and sign in

> Install @dasterhq/daster, connect the daster command to a project and choose the keys the SDK needs.

Source: https://daster.io/docs/sdk-cli-mcp/install-and-sign-in/ · Last updated: 2026-11-21

## Install

Add the SDK to your app:

```bash
npm install @dasterhq/daster
```

Install the `daster` command on your machine, or run it once with `npx`:

```bash
npm install --global @dasterhq/daster
npx @dasterhq/daster --version
```

## Sign 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.

1. Run `daster login`. Add `--write` if the command should be allowed to make changes, such as deploys. Add `--open` to open the address in your browser.
2. The command prints an address under "Approve this connection in DASTER (choose project and environment)". Open it while signed in to DASTER.
3. 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.
4. 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:

```text
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:

```bash
daster login --profile shop-dev --write
daster list
```

`daster 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

```bash
daster logout --profile shop-dev
```

This 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](https://daster.io/docs/getting-started/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](https://daster.io/docs/messaging/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.
