Static Site Template
React static site with Vite. Deploys to Cloud Storage with CDN.
Quick Start
Section titled “Quick Start”# Create projectstacksolo init --template static-site
# Install dependenciescd my-sitenpm install
# Start developmentnpm run devWhat’s Included
Section titled “What’s Included”- React + Vite setup
- TypeScript configured
- Basic routing
- Optimized production build
- CDN deployment config
Project Structure
Section titled “Project Structure”├── apps/web/│ ├── src/│ │ ├── App.tsx│ │ ├── main.tsx│ │ └── pages/│ ├── package.json│ └── vite.config.ts
└── stacksolo.config.jsonAdding Pages
Section titled “Adding Pages”Create new pages in src/pages/:
export default function About() { return ( <div> <h1>About Us</h1> <p>This is the about page.</p> </div> );}Add to your router:
import About from './pages/About';
function App() { return ( <Router> <Routes> <Route path="/" element={<Home />} /> <Route path="/about" element={<About />} /> </Routes> </Router> );}Development
Section titled “Development”# Start dev servernpm run dev
# Build for productionnpm run build
# Preview production buildnpm run previewDeployment
Section titled “Deployment”# Build firstnpm run build
# Deploy to GCPstacksolo deployThis creates:
- Cloud Storage bucket for static files
- Load balancer with CDN caching
- Global anycast IP
- Optional HTTPS with managed certificate
Adding a Custom Domain
Section titled “Adding a Custom Domain”- Update
stacksolo.config.json:
{ "networks": [{ "loadBalancer": { "domain": "www.example.com", "enableHttps": true } }]}- After deployment, configure your DNS to point to the load balancer IP
Adding an API
Section titled “Adding an API”To add a backend API alongside your static site:
- Update
stacksolo.config.json:
{ "networks": [{ "functions": [{ "name": "api", "runtime": "nodejs20", "entryPoint": "api" }], "uis": [{ "name": "web", "framework": "react" }], "loadBalancer": { "routes": [ { "path": "/api/*", "backend": "api" }, { "path": "/*", "backend": "web" } ] } }]}- Create your API in
functions/api/