A modern, production-ready template for building fast and maintainable web applications. This template combines the power of Next.js for server-side rendering and static site generation, Tailwind CSS for rapid UI development, and TypeScript for enhanced code quality and developer experience. Features include:
✨ Modern Stack: Built with Next.js 15, React 19, and TypeScript 5
🎨 Styling: Tailwind CSS with SASS support and a responsive grid system
🛠️ Developer Experience: Comprehensive VS Code setup with ESLint and Prettier
📱 Responsive Design: Mobile-first approach with customizable breakpoints
🚀 Performance: Optimized build configuration for maximum performance
đź”§ Tooling: Pre-configured development tools and scripts
Table of Contents
- Clone the repository:
git clone git@github.com:CFsylvester/next.js-tailwind-typescript-TEMPLATE.git [your-repo-name]
cd [your-repo-name]
- Set up Node.js version:
# Set Node.js version (if using nvm)
nvm use
- Install dependencies:
yarn install
- Run the development server:
yarn dev
Open http://localhost:3000 with your browser to see the result.
When you first open this project in VS Code, you'll automatically be prompted to install the recommended extensions in the bottom right corner. You can also install all recommended extensions at once:
- Open the Command Palette
Cmd/Ctrl + Shift + P
- Type "Show Recommended Extensions"
- Click "Install Workspace Recommended Extensions" (the cloud icon in the top right)
- Prettier - Code formatter - Code formatting
- ESLint - JavaScript/TypeScript linting
- Tailwind CSS IntelliSense - Intelligent Tailwind CSS tooling
- PostCSS Language Support - Modern CSS syntax highlighting
- Auto Rename Tag - Automatically rename paired HTML/JSX tags
- Path Intellisense - Autocomplete filenames
- npm Intellisense - Autocomplete npm modules
- TypeScript Next - Latest TypeScript features
This project includes a .vscode
folder with shared settings for VS Code users. These settings will:
- Set Prettier as the default formatter
- Enable format on save
- Enable ESLint auto-fix on save
- Require a Prettier config file to be present
- Enable enhanced Tailwind CSS IntelliSense features
These settings ensure that:
- All code is automatically formatted on save using Prettier
- ESLint problems are automatically fixed when possible
- The project's Prettier configuration is always used
- Tailwind CSS IntelliSense provides:
- Intelligent CSS class completion
- Syntax highlighting for Tailwind classes
- CSS class suggestions in template strings
- Proper validation of Tailwind classes
- Support for custom class attributes
- Quick suggestions in JSX/TSX files
This project uses:
.nvmrc
for Node.js version management (currently set to v20)engines
in package.json to enforce Node.js (>=20.0.0) and Yarn (>=1.22.0) versionspackageManager
field in package.json to specify exact Yarn version (1.22.22)
To automatically use the correct Node.js version:
- Run
nvm use
in the project directory
The project is configured to use Yarn 1.22.22. When you run yarn install
, it will verify that you're using a compatible version of Yarn. If you have an incompatible version, Yarn will show an error message indicating which version you need to use.
Core styling configuration files:
-
tailwind.config.js - Configuration including:
- Custom breakpoints
- Color palette
- Custom shadows
- Screen sizes
-
src/styles/globals.scss - Global styles including:
- Grid layout system
- Base styles
- Tailwind imports
- React framework for production-grade applications
- JavaScript library for building user interfaces
- Adds static typing to JavaScript
- JavaScript runtime
- Utility-first CSS framework
- CSS preprocessor for enhanced styling
- CSS transformation tool
- Module bundler (built into Next.js)
- Automatically adds vendor prefixes to CSS rules
- Linting utility for JavaScript and TypeScript
- Code formatter for consistent code style
- TypeScript definitions for Node.js
- TypeScript definitions for React
- TypeScript definitions for React DOM
yarn dev
- Run development serveryarn build
- Build for productionyarn start
- Start production serveryarn lint
- Run ESLintyarn lint:fix
- Fix ESLint errorsyarn format
- Format code with Prettieryarn check-format
- Check code formatting
-
In your repository settings, go to Settings > Pages
-
Under Build and deployment:
- Source: Deploy from a branch
- Branch: Select either:
main
and/root
for serving from repository rootmain
and/docs
if using a docs folder
-
Create (or update)
.github/workflows/deploy.yml
:
name: Deploy to GitHub Pages
on:
push:
branches: [main]
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '20'
- name: Install dependencies
run: yarn install
- name: Build
run: yarn build
- name: Deploy
uses: JamesIves/github-pages-deploy-action@v4
with:
branch: gh-pages
folder: out
- Update
next.config.js
:
/** @type {import('next').NextConfig} */
const nextConfig = {
output: 'export', // Enable static exports
basePath: process.env.NODE_ENV === 'production' ? '/your-repo-name' : '',
images: {
unoptimized: true,
},
};
module.exports = nextConfig;
If using a custom domain:
- Add your domain in repository Settings > Pages > Custom domain
- Create a
CNAME
file in your repository root:
your-domain.com
- Update DNS settings with your domain provider:
- Type: CNAME
- Name: www (or subdomain)
- Value: your-username.github.io