Skip to content

Development workflow

This starter kit gives each local service a fixed localhost port and keeps interactive tools in separate terminals. Return to this page while you work. The normal loop is simple: run the app, make one focused change, and check it.

Replace the starter landing page

This starter kit includes a landing page that introduces Launchpad and links to its documentation. Remove that starter content from apps/client/src/routes/index.tsx and replace it with the application's own home page. Update the page title in apps/client/index.html and replace the starter logo in apps/client/public/ when choosing the application's branding.

The docs/ directory contains the starter's documentation site. Applications created from the template can remove it and replace the root README.md with their own setup instructions.

Environment variables

The root .env file holds settings that change between your computer and a production host. Copy the safe template once:

Copy-Item .env.example .env
cp .env.example .env

Generate a value for BETTER_AUTH_SECRET and paste it into .env:

node -e "console.log(require('node:crypto').randomBytes(32).toString('base64'))"

MONGODB_URI identifies the application database. APP_URL and BETTER_AUTH_URL must be the same public origin in this starter. Do not put a secret, database URL, or API key in a variable beginning with VITE_: Vite exposes those to browser code.

Keep .env private

Commit .env.example, never .env. Production hosts should inject the same values through their secret settings instead of copying a development file.

File storage

This starter kit uses RustFS, an Apache 2.0 S3-compatible server, for local file uploads. Keep local development on RustFS; use a separate private Railway, R2, or B2 bucket in production. The Railway deployment guide wires bucket variables automatically and configures browser CORS. The existing S3 client already uses the path-style addressing RustFS needs.

Start local services with Docker

After copying .env.example to the root .env, start MongoDB and RustFS from the repository root:

bun db:up

This starts MongoDB and RustFS from compose.db.yaml. RustFS is pinned to 1.0.0; its API and console bind to host loopback ports 9000 and 9001. Compose reads STORAGE_ACCESS_KEY_ID and STORAGE_SECRET_ACCESS_KEY from the root .env using variable substitution, just like the deployment Compose file. Existing checkouts must copy the five local storage settings from .env.example into .env first. Use only local credentials here.

If MongoDB already runs elsewhere, start only RustFS:

docker compose -f compose.db.yaml up -d --wait rustfs

The API runs on the host, so keep STORAGE_ENDPOINT=http://localhost:9000, STORAGE_REGION=us-east-1, and STORAGE_BUCKET=mern-local. A Docker service name would not resolve from the host or the browser receiving a presigned URL. bun db:down stops both services but preserves their named volumes. Adding --volumes deletes the local database and object storage data.

Create the local bucket once

RustFS does not create the application's bucket at startup. After the Docker services start, open http://localhost:9001, sign in with the configured access and secret keys, and use Create Bucket on the Buckets page to create mern-local (or the exact STORAGE_BUCKET value). Keep the bucket private. The RustFS 1.0.0 console supports this operation; see the official bucket creation guide. The bucket and objects survive restarts in the rustfs-data Docker volume.

For browser uploads, set the bucket's CORS rule to allow http://localhost:3000, methods PUT and GET, and header Content-Type. Alternatively, RustFS supports a server-wide RUSTFS_CORS_ALLOWED_ORIGINS=http://localhost:3000 setting; see the RustFS CORS guide. Use the file upload verification sequence to upload, confirm, and download a file. A healthy container alone does not prove that the bucket exists or that object access works.

Production storage and upload policy

Railway is the recommended production provider for this deployment path; Cloudflare R2 and Backblaze B2 are alternatives. Use a private bucket and credentials that can read, write, and delete objects. The Railway guide supplies these five settings through bucket references. Other hosts inject them through their environment settings:

Variable Value
STORAGE_ENDPOINT The provider's S3 HTTP(S) origin, without a bucket path, query, or embedded credentials
STORAGE_REGION The provider's S3 region value; Railway and R2 may use auto
STORAGE_BUCKET The private bucket name
STORAGE_ACCESS_KEY_ID The storage access key ID; B2 uses an application key ID
STORAGE_SECRET_ACCESS_KEY The corresponding secret access key; B2 uses the application key

For R2, the usual endpoint is https://<account-id>.r2.cloudflarestorage.com. For B2, use https://s3.<region>.backblazeb2.com. Replace the placeholders with the values shown by the provider. Use HTTPS for hosted buckets.

When all five settings are absent, the API starts but authenticated upload requests return 503. If any is supplied, all five must be nonempty or startup fails. Restart the API after changing configuration. Never prefix storage credentials with VITE_ or send them to clients.

The following policy settings already have defaults:

Variable Default Accepted values
STORAGE_MAX_UPLOAD_BYTES 26214400 (25 MiB) Whole bytes from 1 to 5000000000
STORAGE_ALLOWED_MIME_TYPES image/jpeg,image/png,image/webp,application/pdf Comma-separated MIME types with known extensions; no wildcards or empty entries

The allowlist is trimmed and lowercased during configuration parsing. Requests must use an exact resulting MIME type.

For browser uploads, configure the bucket's CORS rules to allow the application origin, PUT and GET, and the Content-Type request header. CORS tells the browser which cross-origin requests it can make; it does not make the bucket public. Use the Railway CORS instructions, the provider's R2 CORS guide, or B2 CORS guide for the provider-specific format.

Follow File uploads to verify the configuration with a direct PUT, confirmation, and private download. Receiving an upload URL alone does not verify bucket access.

Start the workspace

bun dev
bun dev:ui

Run these commands in separate terminals:

  • bun dev: API on http://localhost:3001, MailDev inbox on http://localhost:3003, and SMTP on localhost:3025
  • bun dev:ui: interactive Vite client on http://localhost:3000
  • bun dev:mail: optional React Email preview on http://localhost:3002

Each command owns its terminal. Press Ctrl+C there to stop its processes; Vite's keyboard commands work in the bun dev:ui terminal.

Type check while you work

bun typecheck

This generates TanStack Router route types and runs each package's typecheck script.

Format and lint

bun quality
bun format

bun quality reports lint and formatting problems. bun format writes formatting changes and safe lint fixes. See formatting, linting, and the official Oxfmt and Oxlint documentation.

Build and run

bun run build
bun start

bun run build builds the client and server. bun start runs the compiled server; use the Docker commands in Deployment for the complete production-style stack.

Next step

Continue to Project structure to locate the code each command affects.

References

Related starter documentation: