Prerequisites
Before you begin development, ensure you have:- Node.js v18 or higher (v24 recommended)
- npm, yarn, or pnpm package manager
- Git for version control
- A local instance of the AnimeThemes API (recommended) or access to the production API
Development Server
Starting the Dev Server
Run the development server with hot reload:http://localhost:3000.
Turbopack
The development server uses Turbopack, Next.js’s next-generation bundler:- ⚡ Faster startup - Significantly faster than Webpack
- 🔄 Instant HMR - Hot module replacement happens almost instantly
- 🎯 Optimized builds - Efficient bundling and tree-shaking
Turbopack is enabled by default via the
--turbopack flag in the dev script. It provides a much faster development experience than the traditional Webpack bundler.Available Scripts
Starts the Next.js development server with Turbopack and hot reload on port 3000.
Builds the application for production, generating static pages and optimized bundles.
Starts the production server. Requires running
npm run build first.Runs ESLint to check for code quality issues.
Runs TypeScript compiler in check mode to verify types without emitting files.
Generates TypeScript types from GraphQL schema and queries.
Compiles the TypeScript Next.js config to JavaScript. Runs automatically before dev/build/start.
Project Structure
Path Aliases
TypeScript path aliases are configured for cleaner imports:@/ alias maps to the src/ directory.
Styling with styled-components
Components use styled-components for CSS-in-JS:GraphQL Development
Generating Types
After modifying GraphQL queries or schemas, regenerate TypeScript types:src/lib/common/animethemes/type-defs.ts- AnimeThemes API schemasrc/lib/server/animebracket/type-defs.ts- AnimeBracket schema- All
.tsand.tsxfiles with GraphQL queries
src/generated/graphql.ts- TypeScript types for queriessrc/generated/graphql-resolvers.ts- TypeScript types for resolvers
Writing Queries
Use thegql template tag for type-safe queries:
Git Workflow
Branch Naming
Use descriptive branch names:feature/add-playlist-exportfix/video-player-controlsrefactor/theme-context
Commit Messages
Follow conventional commit format:Pre-commit Hooks
Husky runs checks before each commit:- Linting via ESLint
- Type checking via TypeScript
- Code formatting via Prettier
Debugging
Browser DevTools
Use React DevTools for component inspection and the browser console for debugging.VS Code Debugging
Create.vscode/launch.json:
Verbose Logging
Enable verbose logs via environment variable:Performance Optimization
Build Time Caching
The project uses build-time caching to speed up static generation:next.config.ts
Bundle Analysis
Analyze the bundle size:Common Development Tasks
Adding a new page
Adding a new page
- Create a file in
src/pages/(e.g.,src/pages/about.tsx) - Implement
getStaticPropsfor data fetching - Add the page to navigation if needed
Creating a new component
Creating a new component
- Create a directory in
src/components/(e.g.,src/components/my-component/) - Add component file and styled components
- Export from the component directory
Adding a GraphQL query
Adding a GraphQL query
- Define the query with
gqltag - Use
fetchDataingetStaticProps - Run
npm run graphql-codegento generate types
Changing theme colors
Changing theme colors
- Update
src/theme/colors/index.ts - Restart the dev server
- Test both light and dark modes
Testing
Run type checking to catch TypeScript errors:Next Steps
Add a Page
Learn how to create new pages
Create Components
Build reusable React components
Work with API
Fetch data from the AnimeThemes API
Deploy
Deploy your changes to production