| name | livecodes/self-hosting |
| description | Deploy LiveCodes to static servers, GitHub Pages, or Docker. Configure SDK appUrl, BASE_URL for subdirectories, and handle share/broadcast services. Load this skill when self-hosting LiveCodes or using a custom app URL.
|
| type | composition |
| library | livecodes |
| library_version | 0.13.0 |
| requires | ["sdk-embedding"] |
| sources | ["live-codes/livecodes:docs/docs/features/self-hosting.mdx"] |
This skill requires sdk-embedding. Read it first for foundational concepts.
LiveCodes — Self-Host LiveCodes
LiveCodes runs entirely client-side. Host it on any static file server or CDN.
Deployment Options
Download Release
- Download from GitHub releases
- Extract the
build folder
- Serve from any static host
build/
├── index.html
├── livecodes/
│ ├── assets/
│ └── ...
└── docs/ (optional)
Build from Source
git clone https://github.com/live-codes/livecodes.git
cd livecodes
npm install
npm run build
npm run serve
npm run deploy
GitHub Pages (Built-in)
npm install
npm run deploy
Configure CNAME file for custom domain if needed.
Docker
docker-compose up -d
Docker setup includes:
- HTTPS with auto-certificates
- Share service (short URLs)
- Broadcast server
- Open Graph meta tags
- Custom 404 page
Other Static Hosts
- Cloudflare Pages: Connect repo,
npm run build, serve build/
- Netlify: Connect repo,
npm run build, serve build/
- Firebase Hosting:
firebase init hosting, deploy build/
Configure SDK for Self-Hosted App
import { createPlayground } from 'livecodes';
createPlayground('#container', {
appUrl: 'https://playground.example.com',
template: 'react',
});
The appUrl tells the SDK where to load the playground iframe from.
Custom Build
Subdirectory Hosting
By default, LiveCodes expects to be at the root of a domain. For subdirectories:
npx cross-env BASE_URL="/playground/" npm run build
This sets <base href="/playground/"> and adjusts all asset paths.
Skip Building Docs
To link documentation to livecodes.io instead of building locally:
npx cross-env DOCS_BASE_URL=null npm run build:app
Docs links will point to https://livecodes.io/docs/ instead of local docs.
Services
Self-hosted apps use fallback services:
| Service | Default Hosted | Self-Hosted |
|---|
| Share (short URLs) | dpaste.com (365 days) | dpaste.com or Docker setup |
| Broadcast | LiveCodes server | Docker setup required |
| GitHub Integration | LiveCodes OAuth | Your GitHub App |
Docker for Full Services
Docker setup provides all services:
docker-compose up -d
See docs/docs/advanced/docker.mdx for configuration.
Permanent URL for Stable Embeds
Use versioned URLs to prevent breaking changes:
createPlayground('#container', {
appUrl: 'https://v48.livecodes.io',
template: 'react',
});
import { createPlayground } from 'livecodes@0.13.0';
import { createPlayground } from 'https://cdn.jsdelivr.net/npm/livecodes@0.13.0';
Permanent URLs format: https://v{VERSION}.livecodes.io
Common Mistakes
MEDIUM Not configuring BASE_URL for subdirectories
Wrong:
npm run build
Correct:
npx cross-env BASE_URL="/playground/" npm run build
Without BASE_URL, the app expects to be at root (/) and asset paths will be wrong.
Source: docs/docs/features/self-hosting.mdx — Custom Build section
MEDIUM Self-hosted share URLs expire
The default dpaste.com service deletes shared URLs after one year. For permanent sharing, use Docker setup with your own share service.
Source: docs/docs/features/self-hosting.mdx — Services section
Examples
GitHub Pages
npm install
npm run deploy
Cloudflare Pages
Docker VPS
git clone https://github.com/live-codes/livecodes.git
cd livecodes
docker-compose up -d