This example demonstrates how to use Seatmap Canvas with Next.js Pages Router.
- ✅ SSG (Static Site Generation)
- ✅ ISR (Incremental Static Regeneration)
- ✅ SSR (Server-Side Rendering)
- ✅ Client-Side Rendering with dynamic import
- ✅ TypeScript support
npm installnpm run devOpen http://localhost:3001 to see the examples.
Static Site Generation using getStaticProps.
When to use:
- Content that rarely changes
- Best performance (served as static HTML)
- No runtime data fetching overhead
export const getStaticProps: GetStaticProps = async () => {
const data = await fetchSeatmapData();
return { props: { data } };
};Incremental Static Regeneration with 60-second revalidation.
When to use:
- Content that updates periodically
- Balance between static generation and fresh data
- Background regeneration
export const getStaticProps: GetStaticProps = async () => {
const data = await fetchSeatmapData();
return {
props: { data },
revalidate: 60, // Regenerate every 60 seconds
};
};Server-Side Rendering using getServerSideProps.
When to use:
- Real-time data that changes frequently
- User-specific content
- Always fresh data on every request
export const getServerSideProps: GetServerSideProps = async () => {
const data = await fetchSeatmapData();
return { props: { data } };
};Client-side rendering with dynamic import (SSR disabled).
When to use:
- Interactive features requiring browser APIs
- Avoiding hydration issues
- Client-only functionality
import { SeatmapCanvas } from '@alisaitteke/seatmap-canvas/nextjs/pages-router';
// Automatically uses dynamic import with { ssr: false }nextjs-pages/
├── pages/
│ ├── _app.tsx # App wrapper
│ ├── index.tsx # Home page
│ ├── ssg-example.tsx # SSG example
│ ├── isr-example.tsx # ISR example
│ ├── ssr-example.tsx # SSR example
│ └── client-example.tsx # Client-side example
├── styles/
│ └── globals.css # Global styles
├── next.config.js # Next.js configuration
├── tsconfig.json # TypeScript configuration
└── package.json
Pages Router:
// SSG
export async function getStaticProps() {
return { props: { data } };
}
// SSR
export async function getServerSideProps() {
return { props: { data } };
}App Router:
// Server Component (default)
export default async function Page() {
const data = await fetchData();
return <Component data={data} />;
}Pages Router:
import { SeatmapCanvas } from '@alisaitteke/seatmap-canvas/nextjs/pages-router';
// Pre-configured with { ssr: false }App Router:
'use client';
import { SeatmapCanvas } from '@alisaitteke/seatmap-canvas/nextjs';
// Uses 'use client' directive| Method | Build Time | Runtime | Data Freshness | Use Case |
|---|---|---|---|---|
| SSG | Slow | Fast | Static | Blogs, docs, marketing |
| ISR | Slow | Fast | Periodic | Product catalogs, news |
| SSR | Fast | Slow | Real-time | Dashboards, user profiles |
| CSR | Fast | Medium | Dynamic | Interactive tools, games |
For more information, see:
MIT