Skip to content

ks6088ts/template-typescript-react

Repository files navigation

test e2e-test docker ghcr docker-release github-pages release GitHub release Docker Hub

React TypeScript Vite Vitest Playwright pnpm Biome OpenTelemetry

React + TypeScript + Vite

A starter template for building React single-page apps with TypeScript and Vite — including Biome-based linting/formatting, a two-tier E2E test setup, optional frontend telemetry, and CI/CD to GitHub Pages.

Live demo: https://ks6088ts.github.io/template-typescript-react/

Features

  • ⚡️ Vite dev server with HMR and optimized production builds
  • ⚛️ React 19 + TypeScript
  • 🧹 Biome for linting and formatting (plus actionlint for workflows)
  • 🧪 Vitest (browser mode) + Playwright E2E suites
  • 📊 Optional OpenTelemetry / Application Insights frontend telemetry
  • 🐳 Local Grafana LGTM observability stack via Docker Compose
  • 🚀 GitHub Actions CI/CD with GitHub Pages deployment

Tech stack

Technology Role
TypeScript Static typing
React 19 UI library
Vite Build tool & dev server
pnpm Package manager
Biome Linting and formatting
Vitest (browser mode) Component / integration tests
Playwright E2E smoke tests
OpenTelemetry / Application Insights Optional telemetry
Docker Compose + Grafana LGTM Local observability
GitHub Actions / GitHub Pages CI/CD & hosting

See docs/tech-stack.md for an overview of each technology, its purpose, and the rationale for adoption.

Quick start

Prerequisites: Node.js and pnpm.

# Install dependencies
pnpm install

# Start the dev server (http://localhost:5173)
pnpm dev

# Build for production
pnpm build

# Preview the production build
pnpm preview

# Lint
pnpm lint

# Format
pnpm format

A Makefile wraps common workflows — run make help to list targets (e.g. make ci-test, make e2e, make ci-test-e2e).

Docker

Build and run the production nginx image locally:

# Build the production image
make docker-build

# Run the container (http://localhost:8080)
make docker-run

You can also start the same image with Docker Compose:

docker compose -f docker/compose.yaml up --build web

For Docker-focused CI checks, run:

make ci-test-docker

Published images

Pushing a v* tag keeps the existing release asset flow and also publishes multi-arch (linux/amd64, linux/arm64) images to both registries:

Registry Image Workflow
GitHub Container Registry ghcr.io/ks6088ts/template-typescript-react ghcr-release.yaml
Docker Hub ks6088ts/template-typescript-react docker-release.yaml
# Pull and run from GitHub Container Registry
docker run --rm -p 8080:80 ghcr.io/ks6088ts/template-typescript-react:latest

# Pull and run from Docker Hub
docker run --rm -p 8080:80 ks6088ts/template-typescript-react:latest

The Docker Hub workflow requires two repository secrets: DOCKERHUB_USERNAME and DOCKERHUB_TOKEN (a Docker Hub access token).

Testing

Two E2E suites run headless by default — Vitest browser mode and Playwright:

pnpm exec playwright install chromium
pnpm e2e

Set E2E_HEADED=true to watch the browser UI. See docs/e2e-testing.md for details.

Telemetry

Frontend telemetry is optional and opt-in via environment variables, supporting Application Insights and OpenTelemetry with a local Grafana stack. It is a no-op when unconfigured. See docs/telemetry.md.

Documentation

Project structure

src/                 # React app source
  telemetry/         # Telemetry providers, config, and React bindings
  __tests__/e2e/     # Vitest browser E2E tests
playwright/          # Playwright smoke tests
docker/              # OTel Collector + Grafana LGTM stack
  Dockerfile        # Production nginx image for built SPA assets
docs/                # Detailed documentation
.github/workflows/   # CI/CD pipelines