This guide covers deploying Lyra Web3 Playground to various hosting platforms.
- Git repository with your code
- Node.js 18+ installed locally
- Account on chosen hosting platform
- Environment variables configured
Why Vercel?
- Zero configuration
- Automatic HTTPS
- Global CDN
- Free for hobby projects
- Perfect for Vite/React apps
Steps:
- Push code to GitHub
git add .
git commit -m "Ready for deployment"
git push origin main- Connect to Vercel
npm install -g vercel
vercel login
vercelOr use the web interface:
- Go to vercel.com
- Click "New Project"
- Import your GitHub repository
- Vercel auto-detects Vite configuration
- Click "Deploy"
- Configure Environment Variables
In Vercel Dashboard → Settings → Environment Variables:
VITE_INFURA_API_KEY=your_key_here
VITE_SUPABASE_URL=your_supabase_url
VITE_SUPABASE_ANON_KEY=your_key_here
- Redeploy
Changes pushed to main branch automatically trigger deployment.
Custom Domain:
- Add domain in Vercel dashboard
- Update DNS records as instructed
- HTTPS automatically configured
Steps:
- Create netlify.toml
[build]
command = "npm run build"
publish = "dist"
[[redirects]]
from = "/*"
to = "/index.html"
status = 200
[build.environment]
NODE_VERSION = "18"- Deploy
npm install -g netlify-cli
netlify login
netlify init
netlify deploy --prodOr use web interface:
- Go to netlify.com
- Drag and drop
distfolder - Or connect GitHub repository
- Environment Variables
Add in Site Settings → Build & deploy → Environment variables
Steps:
- Install gh-pages
npm install --save-dev gh-pages- Update package.json
{
"homepage": "https://yourusername.github.io/playground",
"scripts": {
"predeploy": "npm run build",
"deploy": "gh-pages -d dist"
}
}- Update vite.config.ts
export default defineConfig({
base: '/playground/',
// ... rest of config
})- Deploy
npm run deploy- Configure GitHub Pages
- Go to repository Settings → Pages
- Source: gh-pages branch
- Save
For production-grade deployment with AWS
- Build the project
npm run build- Create S3 bucket
aws s3 mb s3://lyra-web3-playground
aws s3 website s3://lyra-web3-playground --index-document index.html --error-document index.html- Upload files
aws s3 sync dist/ s3://lyra-web3-playground --acl public-read- Create CloudFront distribution
aws cloudfront create-distribution \
--origin-domain-name lyra-web3-playground.s3.amazonaws.com \
--default-root-object index.html- Configure DNS
Point your domain to CloudFront distribution URL.
# Build stage
FROM node:18-alpine as builder
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build
# Production stage
FROM nginx:alpine
COPY --from=builder /app/dist /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]server {
listen 80;
server_name localhost;
root /usr/share/nginx/html;
index index.html;
location / {
try_files $uri $uri/ /index.html;
}
# Cache static assets
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ {
expires 1y;
add_header Cache-Control "public, immutable";
}
# Security headers
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-Content-Type-Options "nosniff" always;
add_header X-XSS-Protection "1; mode=block" always;
}docker build -t lyra-web3-playground .
docker run -p 80:80 lyra-web3-playgrounddocker tag lyra-web3-playground yourusername/lyra-web3-playground:latest
docker push yourusername/lyra-web3-playground:latestdeployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: lyra-web3-playground
labels:
app: lyra-web3-playground
spec:
replicas: 3
selector:
matchLabels:
app: lyra-web3-playground
template:
metadata:
labels:
app: lyra-web3-playground
spec:
containers:
- name: lyra-web3-playground
image: yourusername/lyra-web3-playground:latest
ports:
- containerPort: 80
env:
- name: VITE_INFURA_API_KEY
valueFrom:
secretKeyRef:
name: web3-secrets
key: infura-api-key
resources:
requests:
memory: "128Mi"
cpu: "100m"
limits:
memory: "256Mi"
cpu: "200m"service.yaml
apiVersion: v1
kind: Service
metadata:
name: lyra-web3-playground
spec:
selector:
app: lyra-web3-playground
ports:
- port: 80
targetPort: 80
type: LoadBalanceringress.yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: lyra-web3-playground
annotations:
cert-manager.io/cluster-issuer: letsencrypt-prod
spec:
tls:
- hosts:
- lyra-web3-playground.com
secretName: lyra-tls
rules:
- host: lyra-web3-playground.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: lyra-web3-playground
port:
number: 80# Create secrets
kubectl create secret generic web3-secrets \
--from-literal=infura-api-key=your_key_here
# Apply manifests
kubectl apply -f deployment.yaml
kubectl apply -f service.yaml
kubectl apply -f ingress.yaml
# Check status
kubectl get pods
kubectl get services
kubectl get ingress# Blockchain RPC (at least one)
VITE_INFURA_API_KEY=your_infura_key
VITE_ALCHEMY_API_KEY=your_alchemy_key
# Optional but recommended
VITE_SUPABASE_URL=your_supabase_url
VITE_SUPABASE_ANON_KEY=your_supabase_key# AI Features (if enabled)
VITE_OPENAI_API_KEY=your_openai_key
VITE_ANTHROPIC_API_KEY=your_anthropic_key
# Analytics
VITE_PLAUSIBLE_DOMAIN=yourdomain.com
# Premium Features
VITE_STRIPE_PUBLISHABLE_KEY=your_stripe_key
# Feature Flags
VITE_ENABLE_AI_FEATURES=true
VITE_ENABLE_PREMIUM_FEATURES=true1. Enable compression
npm install --save-dev vite-plugin-compression// vite.config.ts
import compression from 'vite-plugin-compression';
export default defineConfig({
plugins: [
react(),
compression({
algorithm: 'gzip',
ext: '.gz',
}),
],
});2. Optimize images
npm install --save-dev vite-plugin-imagemin3. Bundle analysis
npm install --save-dev rollup-plugin-visualizerUse CDN for static assets:
// vite.config.ts
export default defineConfig({
build: {
rollupOptions: {
output: {
assetFileNames: 'assets/[name].[hash][extname]',
},
},
},
});Then configure your CDN (CloudFlare, AWS CloudFront, etc.) to cache /assets/*
npm install @sentry/react @sentry/tracing// src/main.tsx
import * as Sentry from '@sentry/react';
Sentry.init({
dsn: 'your_sentry_dsn',
environment: import.meta.env.MODE,
tracesSampleRate: 1.0,
});npm install plausible-tracker// src/main.tsx
import Plausible from 'plausible-tracker';
const plausible = Plausible({
domain: 'yourdomain.com',
});
plausible.trackPageview();.github/workflows/deploy.yml
name: Deploy
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: '18'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run tests
run: npm test
- name: Build
run: npm run build
env:
VITE_INFURA_API_KEY: ${{ secrets.INFURA_API_KEY }}
- name: Deploy to Vercel
uses: amondnet/vercel-action@v20
with:
vercel-token: ${{ secrets.VERCEL_TOKEN }}
vercel-org-id: ${{ secrets.VERCEL_ORG_ID }}
vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }}Before deploying to production:
- Environment variables properly configured
- No secrets in code or git history
- HTTPS enabled
- Security headers configured
- Dependencies updated and audited
- CSP (Content Security Policy) configured
- Rate limiting on API endpoints
- Input validation on all forms
- XSS protection enabled
- CORS properly configured
# Check if site is accessible
curl https://yourdomain.com
# Check SSL certificate
curl -vI https://yourdomain.com 2>&1 | grep -i ssl
# Test wallet connection
# Open browser and try connecting MetaMask- Set up uptime monitoring (UptimeRobot, Pingdom)
- Monitor Web Vitals
- Set up error alerts
- Monitor API rate limits
If deployment fails:
# Vercel
vercel rollback
# Kubernetes
kubectl rollout undo deployment/lyra-web3-playground
# Docker
docker stop lyra-web3-playground
docker run previous-version-tag- Vercel/Netlify: Free
- GitHub Pages: Free
- Total: $0/month
- Vercel Pro: $20/month
- Infura: Free tier (100k requests/day)
- Supabase: Free tier
- Total: ~$20/month
- AWS/GCP/Azure: $100-500/month
- CloudFront CDN: $50-200/month
- Infura/Alchemy: $50-200/month
- Supabase Pro: $25/month
- Total: $225-925/month
# Clear cache and reinstall
rm -rf node_modules package-lock.json
npm install
npm run build- Check they start with
VITE_ - Verify they're set in hosting platform
- Restart build after adding new variables
Add redirect rules to serve index.html for all routes.
- Enable compression
- Use CDN
- Optimize images
- Code splitting
- Tree shaking
For deployment issues, create an issue on GitHub or check our troubleshooting guide.