Understanding the Pages Router
AnimeThemes Web uses Next.js Pages Router, where files in thesrc/pages/ directory automatically become routes:
src/pages/index.tsx→/src/pages/anime/index.tsx→/animesrc/pages/anime/[animeSlug]/index.tsx→/anime/:animeSlug
Creating a Static Page
Create the page file
Create a new file in
src/pages/. For example, to add a /about page:src/pages/about/index.tsx
Creating a Dynamic Page
Dynamic pages use brackets[param] in the filename to create routes with parameters.
Create the dynamic route file
For example, to create
/artist/[artistSlug]:src/pages/artist/[artistSlug]/index.tsx
Implement getStaticProps
Fetch data at build time using
getStaticProps:src/pages/artist/[artistSlug]/index.tsx
Real Example: Anime Detail Page
Here’s how the anime detail page is structured in the actual codebase:src/pages/anime/[animeSlug]/index.tsx
src/pages/anime/[animeSlug]/index.tsx:54.
Best Practices
- Always include
<SEO />component for proper meta tags - Use TypeScript interfaces for props and params
- Return
notFound: truewhen data doesn’t exist - Add
revalidatefor Incremental Static Regeneration (ISR) - Use
getSharedPageProps()to track API requests - Follow the existing component structure for consistency
Next Steps
- Learn about creating components
- Understand working with the API
- Read about deployment