my-gravito-static-site
v0.1.0
Published
A pre-configured static site template built with Gravito + Inertia.js, ready for deployment to GitHub Pages, Vercel, Netlify, and other static hosting platforms.
Readme
🌐 Gravito Static Site
A pre-configured static site template built with Gravito + Inertia.js, ready for deployment to GitHub Pages, Vercel, Netlify, and other static hosting platforms.
✨ Features
- ✅ StaticLink Component - Automatically handles navigation in static vs dynamic environments
- ✅ Pre-configured Build Script - Ready-to-use static site generation
- ✅ Framework Support - Choose between React or Vue during setup
- ✅ Environment-based Configuration - Configure production domains via environment variables
- ✅ SPA Routing Support - Includes 404.html with SPA routing for GitHub Pages
- ✅ Best Practices - Follows all static site development standards
🚀 Quick Start
1. Create Project
gravito create my-static-site --template static-siteThe CLI will ask you to choose between React or Vue.
2. Configure Environment
Copy env.example to .env and update:
STATIC_SITE_DOMAINS=yourdomain.com,www.yourdomain.com
STATIC_SITE_BASE_URL=https://yourdomain.com3. Install Dependencies
cd my-static-site
bun install4. Start Development
bun run devVisit http://localhost:3000
5. Build Static Site
bun run build:staticThe static files will be generated in dist-static/ directory.
6. Preview Static Site
bun run preview:staticOr manually:
cd dist-static
npx serve .📁 Project Structure
src/
├── bootstrap.ts # Application bootstrap
├── index.ts # Entry point
├── routes/ # Route definitions
├── controllers/ # Controllers
├── hooks/ # Application hooks
├── views/ # Server-side templates
└── client/ # Frontend code
├── app.tsx # React entry (or app.vue.ts for Vue)
├── components/
│ ├── StaticLink.tsx # React StaticLink (or .vue)
│ └── Layout.tsx # Layout component
├── pages/ # Page components
└── styles.css # Global styles🔧 Configuration
Environment Variables
Create a .env file:
# Static Site Configuration
STATIC_SITE_DOMAINS=yourdomain.com,www.yourdomain.com
STATIC_SITE_BASE_URL=https://yourdomain.com
# Development
NODE_ENV=development
PORT=3000Important: For Vite to access these variables in client code, prefix them with VITE_:
VITE_STATIC_SITE_DOMAINS=yourdomain.com,www.yourdomain.comThe build script will automatically inject these into the client bundle.
StaticLink Component
The StaticLink component automatically:
- Uses full page navigation (
<a>tag) in static environments - Uses Inertia navigation (
Linkcomponent) in development - Detects environment based on
VITE_STATIC_SITE_DOMAINSor common static hosting patterns
Usage:
// React
import { StaticLink } from '@/components/StaticLink'
<StaticLink href="/about">About</StaticLink>
// Vue
<StaticLink href="/about">About</StaticLink>🏗️ Building
Build Client Assets
bun run build:clientBuild Static Site
bun run build:staticThis will:
- Build client assets (Vite)
- Generate static HTML for all routes
- Generate
404.htmlwith SPA routing support - Copy static assets
- Generate sitemap.xml
- Create GitHub Pages files (CNAME, .nojekyll)
Output
All static files are generated in dist-static/ directory:
dist-static/
├── index.html
├── about/
│ └── index.html
├── 404.html
├── sitemap.xml
├── CNAME
├── .nojekyll
└── static/
└── build/
└── assets/🚢 Deployment
GitHub Pages
- Build static site:
bun run build:static - Commit
dist-static/togh-pagesbranch - Configure GitHub Pages to serve from
gh-pagesbranch
Vercel
- Build:
bun run build:static - Output directory:
dist-static - Deploy via Vercel CLI or Git integration
Netlify
- Build:
bun run build:static - Publish directory:
dist-static - Deploy via Netlify CLI or Git integration
📚 Documentation
⚠️ Important Notes
- Always use StaticLink - Never use Inertia's
Linkdirectly in static sites - Configure domains - Update
STATIC_SITE_DOMAINSwith your production domains - Test locally - Always test static build locally before deploying
- Environment variables - Use
VITE_prefix for client-side variables
🆘 Troubleshooting
Links don't navigate
- Check: Are you using
StaticLinkinstead of Inertia'sLink? - Check: Is
VITE_STATIC_SITE_DOMAINSconfigured correctly?
404 page doesn't work
- Check: Is
404.htmlgenerated indist-static/? - Check: Does it contain the SPA routing script?
Assets don't load
- Check: Are static assets copied to
dist-static/static/? - Check: Are asset paths correct in generated HTML?
📝 License
MIT
