Deployment Overview
Deploy your Specra documentation to production on any platform
Deployment Overview
Specra is built on SvelteKit, which means you can deploy it almost anywhere. This guide covers the most popular deployment options and how to configure Specra for each.
Deployment Targets
Specra supports two deployment modes:
Specra Cloud (Recommended)
- One-command deploy with the Specra CLI
- Automatic HTTPS with custom subdomains
- Built-in analytics and feedback widgets
- Managed infrastructure — no servers to configure
Static Export (Self-hosted)
- GitHub Pages, Netlify, Cloudflare Pages
- Pre-rendered HTML/CSS/JS
- No server required
- Great for open source docs
Quick Deployment
Specra Cloud (Recommended)
Deploy with two commands using the Specra CLI:
Authenticate
1npx create-specra loginAfter signing in, the auth token is saved to your project's `.env` file as `SPECRA_TOKEN`. This keeps credentials local to each project.
To store the token globally (shared across all projects) instead, use the `--global` flag:
1npx create-specra login --globalThis saves the token to `~/.specra/config.json`.
Deploy
1npx create-specra deployThe CLI builds your project and deploys it to Specra Cloud. You'll get a live URL like `your-project.docs.specra-docs.com`.
Use `--verbose` to see full build output:
1npx create-specra deploy --verboseGitHub Pages
Perfect for open source documentation:
Configure for Static Export
1{2 "deployment": {3 "target": "github-pages",4 "basePath": "your-repo-name",5 "customDomain": false6 }7}Replace your-repo-name with your actual repository name.
Build Static Site
1npm run build:exportThis creates an out/ directory with your static site.
Deploy with GitHub Actions
1name: Deploy to GitHub Pages2 3on:4 push:5 branches: [main]6 7permissions:8 contents: read9 pages: write10 id-token: write11 12jobs:13 build:14 runs-on: ubuntu-latest15 steps:16 - uses: actions/checkout@v417 18 - name: Setup Node.js19 uses: actions/setup-node@v420 with:21 node-version: '20'22 cache: 'npm'23 24 - name: Install dependencies25 run: npm ci26 27 - name: Build site28 run: npm run build:export29 30 - name: Upload artifact31 uses: actions/upload-pages-artifact@v332 with:33 path: ./out34 35 deploy:36 needs: build37 runs-on: ubuntu-latest38 environment:39 name: github-pages40 url: ${{ steps.deployment.outputs.page_url }}41 steps:42 - name: Deploy to GitHub Pages43 id: deployment44 uses: actions/deploy-pages@v4Enable GitHub Pages
- Go to your repo settings
- Navigate to Pages
- Source: GitHub Actions
- Save
Your docs will be live at `https://username.github.io/repo-name`
Netlify
Another great static hosting option:
Configure
1{2 "deployment": {3 "target": "static"4 }5}Create netlify.toml
1[build]2 command = "npm run build:export"3 publish = "out"[[redirects]] from = "/*" to = "/index.html" status = 200
</Step>
<Step title="Deploy">
Connect your repo at [netlify.com](https://netlify.com) or use the CLI:
```bash
npm install -g netlify-cli
netlify deploy --prod
Build Commands
Different platforms need different build commands:
| Platform | Build Command | Output Directory |
|---|---|---|
| Specra Cloud | npx create-specra deploy (handles build) | Managed |
| GitHub Pages | npm run build:export | out |
| Netlify, Cloudflare Pages | npm run build:export | out |
| Docker, VPS | npm run build + npm start | build |
Configuration by Platform
Specra Cloud
No config file needed. The CLI reads your specra.config.json automatically.
To customize the subdomain or project settings, use the Specra dashboard or pass options to the CLI:
1npx create-specra deploy --project my-docsGitHub Pages (No Custom Domain)
1{2 "deployment": {3 "target": "github-pages",4 "basePath": "repo-name"5 }6}Why basePath? GitHub Pages serves from username.github.io/repo-name, so all assets need the /repo-name prefix.
GitHub Pages (With Custom Domain)
1{2 "deployment": {3 "target": "custom-domain-static",4 "customDomain": true5 }6}Add a CNAME file to public/:
docs.yoursite.com
Netlify / Cloudflare Pages
1{2 "deployment": {3 "target": "static"4 }5}No basePath needed - they serve from root.
CI/CD Pipelines
GitHub Actions (Advanced)
Full example with caching and MeiliSearch indexing:
1name: Build and Deploy2 3on:4 push:5 branches: [main]6 pull_request:7 branches: [main]8 9jobs:10 build:11 runs-on: ubuntu-latest12 13 steps:14 - uses: actions/checkout@v415 16 - name: Setup Node.js17 uses: actions/setup-node@v418 with:19 node-version: '20'20 cache: 'npm'21 22 - name: Cache dependencies23 uses: actions/cache@v424 with:25 path: ~/.npm26 key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}27 restore-keys: |28 ${{ runner.os }}-node-29 30 - name: Install dependencies31 run: npm ci32 33 - name: Run linter34 run: npm run lint35 36 - name: Build site37 run: npm run build:export38 env:39 NODE_ENV: production40 41 - name: Index search content42 if: github.ref == 'refs/heads/main'43 run: npm run index:search44 env:45 MEILISEARCH_HOST: ${{ secrets.MEILISEARCH_HOST }}46 MEILISEARCH_API_KEY: ${{ secrets.MEILISEARCH_MASTER_KEY }}47 48 - name: Upload artifact49 uses: actions/upload-pages-artifact@v350 with:51 path: ./out52 53 deploy:54 if: github.ref == 'refs/heads/main'55 needs: build56 runs-on: ubuntu-latest57 environment:58 name: github-pages59 url: ${{ steps.deployment.outputs.page_url }}60 permissions:61 pages: write62 id-token: write63 steps:64 - name: Deploy to GitHub Pages65 id: deployment66 uses: actions/deploy-pages@v4GitLab CI/CD
1# .gitlab-ci.yml2image: node:203 4cache:5 paths:6 - node_modules/7 8stages:9 - build10 - deploy11 12build:13 stage: build14 script:15 - npm ci16 - npm run build:export17 artifacts:18 paths:19 - out/20 only:21 - main22 23pages:24 stage: deploy25 dependencies:26 - build27 script:28 - mkdir -p public29 - cp -r out/* public/30 artifacts:31 paths:32 - public33 only:34 - mainDocker
Create a Dockerfile:
1FROM node:20-alpine AS builder2 3WORKDIR /app4 5COPY package*.json ./6RUN npm ci7 8COPY . .9RUN npm run build10 11FROM node:20-alpine AS runner12 13WORKDIR /app14 15ENV NODE_ENV=production16 17COPY --from=builder /app/public ./public18COPY --from=builder /app/build ./19COPY --from=builder /app/build/client ./build/client20 21EXPOSE 300022 23CMD ["node", "server.js"]Build and run:
1docker build -t my-docs .2docker run -p 3000:3000 my-docsEnvironment Variables
Set these in your deployment platform:
Search (if using MeiliSearch):
1MEILISEARCH_HOST=https://search.example.com2MEILISEARCH_API_KEY=your-search-keyAnalytics (optional):
1PUBLIC_GA_ID=G-XXXXXXXXXX2PUBLIC_PLAUSIBLE_DOMAIN=docs.example.comCustom env variables: Access them in your docs via frontmatter or MDX:
1{2 "env": {3 "API_BASE_URL": "${API_URL}"4 }5}Custom Domains
Specra Cloud
Custom subdomains are automatic. For a fully custom domain:
- Go to your project settings in the Specra dashboard
- Add your custom domain (e.g.,
docs.yoursite.com) - Add a CNAME record pointing to
docs.specra-docs.com - Specra automatically provisions an SSL certificate
GitHub Pages
- Add
CNAMEfile topublic/:
docs.yoursite.com
- Update
specra.config.json:
1{2 "deployment": {3 "customDomain": true4 }5}- Configure DNS:
Type: CNAME
Name: docs
Value: username.github.io
Netlify
- Go to Domain settings
- Add custom domain
- Follow DNS instructions
Performance Optimization
Enable Caching
Add cache headers in svelte.config.js:
1async headers() {2 return [3 {4 source: '/docs/:path*',5 headers: [6 {7 key: 'Cache-Control',8 value: 'public, max-age=3600, must-revalidate',9 },10 ],11 },12 ]13}Image Optimization
Use optimized images:
1<Image2 src="/images/diagram.png"3 alt="Architecture diagram"4 width={800}5 height={600}6/>Bundle Analysis
Check bundle size:
1npm install --save-dev vite-bundle-visualizerRun with:
1ANALYZE=true npm run buildTroubleshooting
404 on Page Refresh (Static Export)
Add redirects/rewrites in platform config:
Netlify:
1[[redirects]]2 from = "/*"3 to = "/index.html"4 status = 200Assets Not Loading (GitHub Pages)
Check your basePath matches your repo name exactly:
1{2 "deployment": {3 "basePath": "exact-repo-name"4 }5}Build Fails
Common fixes:
- Clear build artifacts:
1rm -rf .svelte-kit build node_modules2npm install3npm run build- Check Node.js version:
1node --version # Should be 18+- Review build logs for specific errors
Platform-Specific Guides
Dive deeper into platform-specific deployment:
Specra Cloud
One-command deploy with the CLI
GitHub Pages
Free hosting for open source
Netlify
Static hosting with edge functions