Skip to content
TypeScript
2.8 KB
Raw Blame
---
title: dev
description: Run your stack in development mode with hot reloading — resources deploy to the cloud while Workers run in the local dev runtime.
---

```sh
alchemy dev [options]
```

Run your stack in development mode with hot reloading. Resources are deployed to the cloud while Workers run in the local dev runtime; file changes trigger automatic rebuilds and hot reloads.

## How it works

`dev` re-runs your stack under `bun --watch` (or `node --watch` with type-stripping flags on supported Node versions) via `alchemy/bin/exec`.

`--yes` and dev mode are implied, so approval prompts never appear.

A failed apply keeps dev alive so healthy resources keep serving — fix the error and save to redeploy.

## Flags

| Option              | Description                                                        |
| ------------------- | ------------------------------------------------------------------ |
| `--stage <name>`    | Stage to use for dev (defaults to `$ALCHEMY_STAGE` or `dev_$USER`) |
| `--force`           | Force updates for resources that would otherwise no-op             |
| `--profile <name>`  | Auth profile to use (defaults to `$ALCHEMY_PROFILE` or `default`) |
| `--env-file <path>` | Load environment variables from a file                             |
| `--config, -c <file>`            | Stack file to run (defaults to `alchemy.run.ts`)                   |

`alchemy deploy` defaults to `live_$USER`. Using a different default
here means a bare `alchemy dev` will not replace a stage you deployed.
Pass `--stage` (or `$ALCHEMY_STAGE`) to run local emulation against a specific
stage — including one you also deploy.

Tear the default local-dev stage down with
`alchemy destroy --stage dev_$USER`.

## Environment variables

| Variable                   | Description                                                                                                       |
| -------------------------- | ----------------------------------------------------------------------------------------------------------------- |
| `ALCHEMY_WORKERD_PATH`     | Path to the `workerd` binary every local Workers runtime runs, instead of the one from npm (e.g. on NixOS)        |
| `ALCHEMY_WORKERD_V8_FLAGS` | Extra V8 flags for every local Workers runtime, separated by whitespace (e.g. `--max-old-space-size=4096`)        |

A Worker's `dev.workerd` option sets the same things for that Worker alone, and wins over these.

## Examples

```sh
# Start dev mode (stage dev_$USER)
alchemy dev

# Emulate the prod program locally (replaces that stage's local/live mode)
alchemy dev --stage prod
```

## Where next

- [logs](/cli/logs) fetches past logs or tails them with `--tail`
- [deploy](/cli/deploy) — deploy for real
- [Local development](/environments/local-development) — how dev mode works under the hood