---
title: "Local development"
description: "Bootstrap the EdgeCart workspace, apply D1 migrations, and run the storefront and admin on localhost."
---

> Documentation Index
> Fetch the complete documentation index at: https://edgecart.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Local development

This guide takes you from a clean checkout to a running storefront and admin on
`http://localhost:3000`.

## Before you start

- **Node.js 22+** and **pnpm 10+**.
- A Cloudflare account if you want to create the remote D1 database now. A
  local-only setup can skip remote D1 creation.
- macOS/Linux shell (the bootstrap script is Bash).

## Steps

1. **Clone the repository**

   ```sh
   git clone <your-edgecart-repository> edgecart
   cd edgecart
   ```
2. **Bootstrap the workspace**

   For a local-only setup that does not create a remote D1 database:

   ```sh
   SKIP_D1_CREATE=1 pnpm bootstrap
   ```

   To create the Cloudflare D1 database now, sign in first and run the default
   bootstrap:

   ```sh
   pnpm --filter edgecart exec wrangler login
   pnpm bootstrap
   ```

   `pnpm bootstrap` installs dependencies, creates the D1 database when the
   `database_id` is still the all-zero placeholder, and applies migrations
   locally. It is safe to re-run.
3. **Create the local environment file**

   ```sh
   cp apps/edgecart/.dev.vars.example apps/edgecart/.dev.vars
   ```

   Set `BETTER_AUTH_SECRET` to a random value:

   ```sh
   openssl rand -base64 32
   ```

   Keep the default local values for `BETTER_AUTH_URL` and `TRUSTED_ORIGINS`:

   ```dotenv
   BETTER_AUTH_SECRET=<generated-value>
   BETTER_AUTH_URL=http://localhost:3000
   TRUSTED_ORIGINS=http://localhost:3000
   ```
4. **Start the app**

   ```sh
   pnpm dev
   ```

   Open `http://localhost:3000`. The storefront is at `/`, the admin at
   `/admin`.
5. **Create the first account**

   Open `/signup` and create an account. With `SMTP_HOST` empty, auth email is
   skipped and logged in the dev server output instead of being sent.

   Then open `/admin`. The first signed-in user becomes the owner of the
   deployment's store, created as **My Store**.

## Optional: test payments

The storefront checkout needs Stripe test keys in `.dev.vars`:

```dotenv
STRIPE_SECRET_KEY=sk_test_...
STRIPE_PUBLISHABLE_KEY=pk_test_...
STRIPE_WEBHOOK_SECRET=whsec_...
```

Use the Stripe CLI to forward webhook events:

```sh
pnpm stripe:listen
```

Without Stripe keys, you can still build the catalog and test zero-total carts;
paid checkout is blocked by the payment gate.

## Verify

- `pnpm dev` starts without migration errors.
- `http://localhost:3000` renders the storefront.
- `/admin` opens and shows the dashboard for your store.

## Troubleshooting

**Bootstrap fails creating D1.** You are not logged in to Cloudflare, or the
database already exists. Run `pnpm --filter edgecart exec wrangler login` and
retry, or use `SKIP_D1_CREATE=1 pnpm bootstrap` for local-only work.

**`Missing BETTER_AUTH_SECRET`.** The app reads `apps/edgecart/.dev.vars`; make
sure you copied the example and replaced the secret.

**Changes do not appear in D1.** Apply local migrations with
`pnpm db:migrate:local`.

## Next

- [Browse the API reference](https://edgecart.dev/api)
- [Understand the commerce modules](https://edgecart.dev/modules/)
- [Check current limitations](https://edgecart.dev/reference/limitations)

Source: https://edgecart.dev/developers/local-development/index.mdx
