Skip to content

Local Development

This guide covers advanced local development topics. For basic setup, see the Quick Start.

Development Tips

  • TypeScript Execution: Use pnpx tsx instead of npx ts-node to run TypeScript files
  • Browser DevTools: Check Application → Storage to verify storage partitioning
  • Hot Reload: Changes in swarm-ui/src/ will automatically reload in the browser
  • Debugging: Use browser DevTools on both the parent page and the iframe
  • Library changes: If you change library code, rebuild it with cd lib && pnpm build, or use cd lib && pnpm build:watch for automatic rebuilds

Client-Side Stamp Signing

Stamps bought via the local Bee API are owned by the queen node. Use the queen’s private key for client-side signing:

import { Stamper } from '@ethersphere/bee-js'
const queenKey = '566058308ad5fa3888173c741a1fb902c9f1f19559b11fc2738dfc53637ce4e9'
const stamper = Stamper.fromBlank(queenKey, batchId, depth)
const envelope = stamper.stamp(chunk)

Known Dev Keys

These are the pre-funded keys available in the local FDP Play Bee cluster:

NodePrivate KeyAddress
Queen566058308ad5fa3888173c741a1fb902c9f1f19559b11fc2738dfc53637ce4e90x26234a2ad3ba8b398a762f279b792cfacd536a3f
Worker 1195cf6324303f6941ad119d0a1d2e862d810078e1370b8d205552a543ff40aab-

Testing with Real Domains (SSH Tunnel)

To test storage partitioning behavior with real TLS certificates (as in production), you can use SSH tunnels to a VPS with nginx.

Architecture

Your VPS (nginx + HTTPS) Your Local Machine
┌─────────────────────────┐ ┌─────────────────────┐
│ demo.yourdomain.com │◄──────────│ SSH -R tunnels │
│ → 127.0.0.1:18080 │ │ 18080 → demo │
│ id.yourdomain.com │ │ 5174 → identity │
│ → 127.0.0.1:5174 │ │ (Vite dev server) │
└─────────────────────────┘ └─────────────────────┘

VPS Setup (one-time)

  1. Add nginx server blocks pointing to 127.0.0.1:18080 (demo) and 127.0.0.1:5174 (identity)
  2. Get SSL certificates with certbot
  3. Add DNS A records for both subdomains

Local Usage

Terminal window
# Terminal 1: Start demo server
pnpm dev:demo
# Terminal 2: Start SvelteKit dev server with allowed hosts
VITE_ADDITIONAL_SERVER_ALLOWED_HOSTS=id.yourdomain.com pnpm dev:swarm-ui
# Terminal 3: Open SSH tunnel
ssh -R 18080:localhost:3000 -R 5174:localhost:5174 user@your-vps

The VITE_ADDITIONAL_SERVER_ALLOWED_HOSTS environment variable is required when accessing the Vite dev server through a foreign hostname. Without it, Vite will reject requests from the tunneled domain.

Access the Demo

https://demo.yourdomain.com/?idDomain=https://id.yourdomain.com

The ?idDomain= parameter tells the demo which identity service to use. This allows testing cross-origin storage partitioning with real browser security policies while still having hot reload for the identity UI.