This demo showcases a modern, performant mega navigation solution built with Next.js that solves two key problems:
- How to update navigation without revalidating all ISR pages that use it
- How to achieve optimal Core Web Vitals while keeping navigation data fresh
- Initial render is done on the server using build-time data
- Client-side updates using SWR for data freshness
- Zero Cumulative Layout Shift (CLS) due to CSS-first approach
- Navigation data is always fresh in the client without affecting page performance
- Navigation endpoint is cached (like ISR) and can be revalidated using
revalidatePath - All product pages are static (ISR) with time-based revalidation (1 hour)
- Perfect for large sites with thousands of pages - update navigation without revalidating all pages
- See the implementation in app/api/navigation/route.ts
- Time interval updates (default: 10 seconds)
- Can be configured for:
- On focus updates
- On mount updates
- Manual refresh
- See the configuration in components/MegaNav.tsx
- Product links in the menu include timestamps
- Initial load shows stale timestamps
- Real-time updates when using the website
- CSS-first approach inspired by M&S MegaNav: View on CodePen
To verify the CSS-first implementation and its benefits:
- Open the page in Chrome Browser
- Disable JavaScript (DevTools > Settings > Debugger > Disable JavaScript)
- Notice how:
- The responsive design works perfectly on both mobile and desktop
- The MegaNav renders and functions without any JavaScript
- On desktop, the dropdown menus work with pure CSS hover states
- On mobile, the menu is accessible and responsive
- This approach ensures:
- Perfect Core Web Vitals (CWV) scores
- No JavaScript blocking the main thread
- Immediate visual feedback for user interactions
- Progressive enhancement when JavaScript is available
First, run the development server:
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun devOpen http://localhost:3000 with your browser to see the result.
The demo uses several Next.js features:
- App Router for server components
- Route Handlers for the navigation API
- SWR for client-side data fetching
- CSS-first approach for optimal performance
To learn more about the technologies used:
The easiest way to deploy your Next.js app is to use the Vercel Platform from the creators of Next.js.
Check out our Next.js deployment documentation for more details.

