SvelteKit Local Dev
Develop a SvelteKit app locally while using remote OAuth, database, and services.
- Local SvelteKit dev server at
localhost:5173 - Accessible via production domain
app.example.com - Connected to remote PostgreSQL database
- OAuth callbacks work correctly
Prerequisites
Section titled “Prerequisites”- Deployed infrastructure with auth service and database
- Dev proxy set up:
slipp bootstrap proxy myserver --email admin@example.com - Vault secrets configured
-
Create run profile
Terminal window slipp run dev \--cmd "npm run dev" \--tunnel-out 5173:app.example.com@myserver \--tunnel-in postgres:5432@myserver \--vault myproject -
Configure environment
Your
.env.localshould reference localhost for tunneled services:.env.local DATABASE_URL=postgresql://user:pass@localhost:5432/mydbPUBLIC_APP_URL=https://app.example.com -
Run development
Terminal window slipp run dev
How It Works
Section titled “How It Works”sequenceDiagram
participant Browser
participant Caddy as VPS Caddy
participant TunnelOut as SSH Tunnel (out)
participant Dev as SvelteKit Dev
participant TunnelIn as SSH Tunnel (in)
participant DB as Remote PostgreSQL
Browser->>Caddy: app.example.com
Caddy->>TunnelOut: Route to tunnel
TunnelOut->>Dev: localhost:5173
Dev->>TunnelIn: localhost:5432
TunnelIn->>DB: Query
DB-->>Browser: Response
OAuth Callbacks
Section titled “OAuth Callbacks”Since your app is accessible at the production domain:
- OAuth provider redirects to
https://app.example.com/auth/callback - Request tunnels to your local server
- Session is established locally
- Refresh and it works!
No need to configure localhost callback URLs.
Database Migrations
Section titled “Database Migrations”Run migrations against remote database:
# With tunnel activenpx prisma migrate deploy
# Or Drizzlenpm run db:pushMultiple Developers
Section titled “Multiple Developers”Each developer needs their own domain:
# Developer 1slipp run dev --tunnel-out 5173:alice.app.example.com@myserver
# Developer 2slipp run dev --tunnel-out 5173:bob.app.example.com@myserverConfigure DNS wildcards or separate A records.