Skip to content

enijar/web-template

Repository files navigation

Web Template

A full-stack TypeScript template with React, Hono, and tRPC.

Quickstart

cp .env.example .env.local
npm install
npm start

This starts the client at localhost:8080 and the server at localhost:3000.

Environment Variables

Dotenvx is used for storing encrypted environment variables in version control. This makes deployment and sharing configs easier. Ensure .env.keys is never committed, and that when decrypting the .env.* files, they are encrypted before committing them. Use .env.local to override existing variables with your own values.

Production

npm run build
pm2 startOrReload ecosystem.config.cjs --time --update-env

The CI workflow builds on the GitHub runner, rsyncs build and node_modules to the server, then reloads pm2. Because node_modules is copied as-is, the runner and the server must share the same OS and CPU architecture so native modules such as argon2 stay compatible. If they differ, run npm rebuild on the server after syncing, or change the workflow to run npm ci on the server instead.

Example NGINX config:

server {
    server_name _;
    listen 80;
    listen [::]:80;
    client_max_body_size 500m;

    index index.html;
    root /var/www/project-name/build/client;

    location / {
        try_files $uri $uri/ /index.html =404;
    }

    location ~ ^/(api|trpc) {
        proxy_redirect off;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
        proxy_pass http://localhost:3000;
    }
}

About

Opinionated template for building modern and scalable web projects.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors