Netlify
Static Site HostingEasyFree / Paid
Popular platform for static site hosting with automatic deployments from Git
Best For: Static React apps, SPAs, JAMstack sites
Automatic deployments from GitBuilt-in CI/CDEdge functionsForm handlingCustom domainsSSL certificates
Setup Commands
1# 1. Build your React app2npm run build34# 2. Install Netlify CLI5npm install -g netlify-cli67# 3. Login to Netlify8netlify login910# 4. Deploy from build folder11netlify deploy --prod --dir=build
Configuration
1# netlify.toml2[build]3 publish = "build"4 command = "npm run build"56[[redirects]]7 from = "/*"8 to = "/index.html"9 status = 2001011[build.environment]12 NODE_VERSION = "20"13 NPM_VERSION = "10"1415# Environment variables16[context.production.environment]17 REACT_APP_API_URL = "https://api.example.com"1819[context.deploy-preview.environment]20 REACT_APP_API_URL = "https://staging-api.example.com"
CI/CD Workflow
1# .github/workflows/netlify.yml2name: Deploy to Netlify34on:5 push:6 branches: [ main ]7 pull_request:8 branches: [ main ]910jobs:11 build:12 runs-on: ubuntu-latest1314 steps:15 - uses: actions/checkout@v31617 - name: Setup Node.js18 uses: actions/setup-node@v319 with:20 node-version: '20'21 cache: 'npm'2223 - name: Install dependencies24 run: npm ci2526 - name: Run tests27 run: npm test -- --coverage --watchAll=false2829 - name: Build application30 run: npm run build3132 - name: Deploy to Netlify33 uses: netlify/actions/cli@master34 with:35 args: deploy --prod --dir=build36 env:37 NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}38 NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
Advantages
- ✓Easy setup and deployment
- ✓Automatic SSL certificates
- ✓Global CDN
- ✓Branch previews
- ✓Built-in form handling
Considerations
- ⚠️Limited server-side capabilities
- ⚠️Build time limits on free plan
- ⚠️No database hosting