No description
Find a file
jasmine 304367cde5
Remove bun.lockb from templates
Users will generate their own lockfile on first install. This avoids
binary file issues with omnix text substitution and ensures fresh
dependency resolution.
2025-11-14 11:35:19 +08:00
nix/modules Revert "Exclude bun.lockb from omnix text substitution" 2025-11-14 11:34:26 +08:00
templates Remove bun.lockb from templates 2025-11-14 11:35:19 +08:00
.envrc Initial commit: minimal JavaScript template with Nix 2025-10-27 21:24:12 +08:00
.gitignore Remove bun.lockb from templates 2025-11-14 11:35:19 +08:00
flake.lock Initial commit: minimal JavaScript template with Nix 2025-10-27 21:24:12 +08:00
flake.nix Refactor into multi-template monorepo with Next.js support 2025-11-14 11:16:04 +08:00
LICENSE Initial commit: minimal JavaScript template with Nix 2025-10-27 21:24:12 +08:00
README.md Refactor into multi-template monorepo with Next.js support 2025-11-14 11:16:04 +08:00

JavaScript Templates

A family of minimal JavaScript development templates using Nix for reproducible environments. Choose the right foundation for your project while maintaining consistent tooling and workflows.

Available Templates

Vanilla

Minimal JavaScript template for interactive sites and applications.

Best for:

  • Interactive tools and utilities
  • Client-side games
  • Dashboards and data visualizations
  • Projects that don't need a framework

Tech stack:

  • Vite (development server & bundler)
  • Vanilla JavaScript (no framework)
  • Node.js REPL with custom helpers

Next.js

TypeScript template with App Router for modern web applications.

Best for:

  • Full-stack applications (e-commerce, SaaS)
  • Static sites with growth potential
  • Projects needing API routes
  • Server-side rendering or static generation

Tech stack:

  • Next.js 15 with App Router
  • React 19
  • TypeScript
  • Optimized for Vercel deployment

Shared Foundation

All templates include:

  • Nix + Flakes - reproducible development environments
  • Bun - fast JavaScript runtime & package manager
  • ESLint + Prettier - code quality and formatting
  • just - consistent command-line interface
  • FHS compatibility - toggle for NixOS edge cases

Getting Started

Prerequisites

  • Nix with flakes enabled
  • direnv (optional but recommended)

Initialize a Project

Using omnix:

Vanilla template:

nix run nixpkgs#omnix -- \
  init github:sajenim/javascript-templates -o ./my-project

Next.js template:

nix run nixpkgs#omnix -- \
  init github:sajenim/javascript-templates#nextjs -o ./my-nextjs-app

Enter Development Environment

cd my-project
direnv allow  # Or use: nix develop
just dev

NixOS FHS Compatibility

If bun-installed binaries fail to find system libraries, enable FHS compatibility:

# nix/modules/devshell.nix
fhs = true;

Common Commands

Both templates share the same command interface:

just           # List all available commands
just dev       # Start development server
just build     # Production build
just lint      # Lint code
just format    # Format code
just clean     # Clean build artifacts
just update    # Update Nix flake inputs
just upgrade   # Upgrade package dependencies

Template-Specific Commands

Vanilla:

just repl      # Node.js REPL with custom helpers
just preview   # Preview production build

Next.js:

just start     # Start production server
just typecheck # TypeScript type checking
just check     # Run format-check, lint, and typecheck

Next.js Static Export

For pure static sites (no server-side features), enable static export:

// templates/nextjs/next.config.js
const nextConfig = {
  output: 'export',
  // ...
};

Note: This disables API routes and server-side rendering.

Customization

All templates provide minimal, sensible defaults. Customize as needed:

Vanilla:

  • Modify linting rules in eslint.config.js
  • Add custom REPL helpers in .replrc.js
  • Extend Vite config if needed

Next.js:

  • Configure Next.js in next.config.js
  • Customize ESLint rules in .eslintrc.json
  • Adjust TypeScript settings in tsconfig.json
  • Extend ESLint config for stricter rules

Both templates:

  • Add Prettier config via .prettierrc if needed
  • Extend Justfile with project-specific commands
  • Adjust Nix devshell in nix/modules/devshell.nix

Template Comparison

Feature Vanilla Next.js
Framework None Next.js
Language JS TS
Bundler Vite Next.js
Client-side only
Server-side API
Static generation
Type checking
React components
File-based routing

Acknowledgments

License

MIT