A modern, production-ready Next.js boilerplate featuring TypeScript, Emotion, Radix UI, and comprehensive development tooling. Built for scalability, accessibility, and developer experience.
- π Next.js 16.1.1 with App Router and Turbopack
- βοΈ React 19.2.3 with concurrent features and improved performance
- π TypeScript 5.9.3 with strict configuration and path mapping
- π¨ Modern Styling: Radix UI Themes + Tailwind CSS for maximum flexibility
- βΏ Accessible UI: Radix UI primitives with ARIA compliance and 30+ color scales
- π§ͺ Testing Suite: Jest + Testing Library with comprehensive coverage
- π§ Developer Experience: ESLint, Prettier, Husky, and lint-staged
- π± Mobile-First: Responsive design with Radix Themes layout engine
- π― Performance: Optimized builds, server components, and code splitting
- π¦ Modern Tooling: Bun runtime, hot reloading, and bundle analysis
- π Error Debugging: Sentry integration for production error tracking
βββ π src/
β βββ π app/ # Next.js App Router
β β βββ π layout.tsx # Root layout with Theme Provider
β β βββ π page.tsx # Homepage with demos
β β βββ π globals.css # Global styles
β β βββ π fonts/ # Custom fonts
β βββ π domain/ # Business logic (Clean Architecture)
β β βββ π entities/ # Domain entities
β β βββ π events/ # Domain events
β β βββ π services/ # Domain services
β β βββ π value-objects/ # Value objects
β βββ π application/ # Application layer
β β βββ π dtos/ # Data transfer objects
β β βββ π ports/ # Interface definitions
β β βββ π use-cases/ # Application use cases
β βββ π infrastructure/ # External integrations
β β βββ π adapters/ # Repository implementations
β β βββ π config/ # Dependency injection
β β βββ π external/ # External service integrations
β βββ π presentation/ # UI layer
β β βββ π components/ # Reusable UI components
β β βββ π hooks/ # Custom React hooks
β β βββ π pages/ # Page components
β β βββ π styles/ # Component styles
β βββ π lib/ # Shared utilities
β βββ π utils/ # Helper functions
βββ π .storybook/ # Storybook configuration
βββ π scripts/ # Build and utility scripts
βββ π next.config.mjs # Next.js configuration
βββ π tailwind.config.ts # Tailwind CSS config
βββ π tsconfig.json # TypeScript configuration
βββ π jest.config.js # Jest testing config
βββ π eslint.config.js # ESLint configuration
βββ π prettier.config.js # Prettier formatting config
- Node.js 18.17.0+ or Bun 1.0.0+
- npm 9.0.0+ (comes with Node.js)
-
Clone the repository
git clone https://github.com/bivex/next-boilerplate.git cd next-boilerplate -
Install dependencies
# Using Bun (recommended for speed) bun install # Or using npm npm install # Or using yarn yarn install
-
Start development server
# Using Bun bun dev # Or using npm npm run dev
-
Open your browser
Navigate to http://localhost:3000 to see the boilerplate in action!
This boilerplate uses a modern styling approach combining Radix UI Themes with Tailwind CSS:
<Flex align="center" justify="between" p="4" className="rounded-lg bg-white shadow-md">
<Heading size="4">Title</Heading>
<Button variant="solid">Action</Button>
</Flex><div className="flex items-center justify-between rounded-lg bg-white p-4 shadow-md">
<h2 className="text-xl font-semibold text-gray-900">Title</h2>
<Button className="bg-blue-600 hover:bg-blue-700">Action</Button>
</div>import { Button, Dialog, TextField, Select, Checkbox, RadioGroup } from '@radix-ui/themes';
// Buttons with variants and sizes
<Button size="3" variant="solid" color="blue">Solid Button</Button>
<Button size="2" variant="soft" color="gray">Soft Button</Button>
<Button size="1" variant="outline">Outline Button</Button>
// Form components
<TextField.Root placeholder="Enter your name">
<TextField.Slot>π€</TextField.Slot>
</TextField.Root>
<Select.Root>
<Select.Trigger placeholder="Choose an option" />
<Select.Content>
<Select.Item value="1">Option 1</Select.Item>
<Select.Item value="2">Option 2</Select.Item>
</Select.Content>
</Select.Root>
// Layout components
<Flex gap="4" align="center">
<Box>Item 1</Box>
<Box>Item 2</Box>
</Flex>- Form Controls: Button, TextField, TextArea, Select, Checkbox, RadioGroup
- Layout: Box, Flex, Grid, Container, Section
- Navigation: Tabs, DropdownMenu, ContextMenu
- Feedback: Dialog, AlertDialog, Toast, Tooltip
- Data Display: Table, DataList, Badge, Avatar
- Progress: Progress, Skeleton, Spinner
import { Dialog, Button, Flex, Text } from '@radix-ui/themes';
import { useState } from 'react';
function MyComponent() {
const [isOpen, setIsOpen] = useState(false);
return (
<>
<Button onClick={() => setIsOpen(true)}>Open Dialog</Button>
<Dialog.Root open={isOpen} onOpenChange={setIsOpen}>
<Dialog.Content>
<Dialog.Title>Confirm Action</Dialog.Title>
<Dialog.Description>Are you sure you want to proceed?</Dialog.Description>
<Flex direction="column" gap="4" mt="4">
<Text>This action cannot be undone.</Text>
<Flex gap="3" justify="end">
<Dialog.Close>
<Button variant="soft" color="gray">
Cancel
</Button>
</Dialog.Close>
<Dialog.Close>
<Button variant="solid">Confirm</Button>
</Dialog.Close>
</Flex>
</Flex>
</Dialog.Content>
</Dialog.Root>
</>
);
}The theme system uses Radix UI Themes 3.0 with comprehensive design tokens:
// app/layout.tsx
import { Theme } from '@radix-ui/themes';
export default function RootLayout({ children }) {
return (
<html lang="en">
<body>
<Theme appearance="light" accentColor="blue" radius="medium">
{children}
</Theme>
</body>
</html>
);
}- 30+ Accessible Color Scales - From gray to vibrant colors
- Responsive Object Syntax - Mobile-first responsive design
- CSS Custom Properties - Runtime theme switching
- Dark Mode Support - Built-in light/dark theme switching
- Component Variants - Buttons, inputs, and layouts
- Layout Engine - Flex, Grid, and responsive utilities
// Automatic theme colors
<Button color="blue" variant="solid">Primary Action</Button>
<Button color="gray" variant="soft">Secondary Action</Button>
// Custom styling with theme integration
<Box p="4" style={{ backgroundColor: 'var(--color-background)' }}>
<Text color="gray">Themed content</Text>
</Box>This boilerplate includes a comprehensive testing setup:
# Run all tests
npm test
# Run tests in watch mode
npm run test:watch
# Run tests with coverage
npm run test:coverage
# Run tests in CI mode
npm run test:ci// Component testing with Radix UI Themes
import { render, screen } from '@testing-library/react';
import { Theme } from '@radix-ui/themes';
import { Button } from '@radix-ui/themes';
const renderWithTheme = component => render(<Theme>{component}</Theme>);
describe('Button', () => {
it('renders with theme correctly', () => {
renderWithTheme(<Button>Test Button</Button>);
expect(screen.getByText('Test Button')).toBeInTheDocument();
});
});// src/components/Button.test.tsx
import { render, screen, fireEvent } from '@testing-library/react';
import { Button } from './Button';
describe('Button', () => {
it('renders children correctly', () => {
render(<Button>Click me</Button>);
expect(screen.getByText('Click me')).toBeInTheDocument();
});
it('handles click events', () => {
const handleClick = jest.fn();
render(<Button onClick={handleClick}>Click me</Button>);
fireEvent.click(screen.getByText('Click me'));
expect(handleClick).toHaveBeenCalledTimes(1);
});
it('applies correct variants', () => {
render(<Button variant="primary">Primary</Button>);
const button = screen.getByText('Primary');
expect(button).toHaveClass('bg-blue-600');
});
});| Command | Description |
|---|---|
npm run dev |
Start development server with Turbopack |
npm run build |
Build for production |
npm run build:analyze |
Build with bundle analyzer |
npm run start |
Start production server |
npm run lint |
Run ESLint |
npm run lint:fix |
Fix ESLint issues automatically |
npm run lint:strict |
Run ESLint with zero warnings |
npm run type-check |
Run TypeScript type checking |
npm run test |
Run Jest tests |
npm run test:coverage |
Run tests with coverage report |
npm run format |
Format code with Prettier |
npm run clean |
Clean build artifacts and caches |
For even faster development, use Bun commands:
bun dev # Development server
bun build # Production build
bun test # Run tests
bun run lint # Run lintingThe next.config.mjs includes optimizations for:
- Image optimization with next/image
- Bundle analysis with webpack-bundle-analyzer
- Compression and caching headers
- Security headers and CSP
- PWA support ready
Strict TypeScript setup with:
- Path mapping (
@/components,@/lib, etc.) - Strict mode enabled
- ESNext modules support
- React 18 types
Comprehensive linting with:
- Next.js rules
- TypeScript rules
- React hooks rules
- Accessibility rules
- Import sorting
- Prettier integration
- Connect your repository to Vercel
- Configure build settings:
- Build Command:
npm run build - Output Directory:
.next - Install Command:
npm install
- Build Command:
- Add environment variables if needed
- Deploy automatically on every push
# Build command
npm run build
# Publish directory
.next# Build command
npm run build
# Start command
npm startFROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY . .
RUN npm run build
EXPOSE 3000
CMD ["npm", "start"]This boilerplate includes Sentry integration with Spotlight for comprehensive error tracking and local debugging.
-
Get your Sentry DSN
- Create a project at sentry.io
- Copy your DSN from Project Settings > Client Keys
-
Configure Environment Variables
cp .env.example .env.local
Edit
.env.local:SENTRY_DSN=https://your-dsn@sentry.io/project-id NEXT_PUBLIC_SENTRY_DSN=https://your-dsn@sentry.io/project-id
-
Run with Spotlight (Development)
npm run dev:spotlight
This starts both your Next.js app and Spotlight's debugging overlay.
-
Features
- Production Error Tracking: Automatic error reporting to Sentry
- Local Debugging: Spotlight overlay shows errors in real-time during development
- Performance Monitoring: Request tracing and performance metrics
- Session Replays: User interaction recordings for debugging
- Development: Spotlight overlay appears for real-time debugging
- Production: Errors are sent to Sentry dashboard only
For detailed setup instructions, see the Sentry Next.js docs and Spotlight docs.
We welcome contributions! Please see our Contributing Guide for details.
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Make your changes and ensure tests pass
- Run the full test suite:
npm run test:ci - Commit with conventional commits:
git commit -m "feat: add amazing feature" - Push to your branch:
git push origin feature/amazing-feature - Open a Pull Request
- ESLint: All code must pass linting
- TypeScript: Strict type checking enabled
- Prettier: Consistent code formatting
- Testing: Minimum 80% coverage required
- Accessibility: WCAG 2.1 AA compliance
This project is licensed under the MIT License - see the LICENSE file for details.
- Next.js - The React framework
- Radix UI - Accessible component primitives and themes
- Tailwind CSS - Utility-first CSS framework
- TypeScript - Type-safe JavaScript
- Jest - Testing framework
- Sentry - Error tracking and monitoring
- π§ Email: support@b-b.top
- π Issues: GitHub Issues
- π¬ Discussions: GitHub Discussions
Built with β€οΈ using modern web technologies