Next.js Edge Functions Cheat Sheet

Middleware, API routes, and caching at the edge

Last Updated: November 21, 2025

Focus Areas

Focus
Use middleware for auth checks and redirection at the edge
Enable caching headers to reuse responses safely

Commands & Queries

npx next dev
Run the Next.js dev server
export const config = { runtime: 'edge' }
Mark functions for the edge
cache-control: public, max-age=60
Tune caching headers

Summary

Ship edge-friendly routes and caches by keeping functions small and pure.

💡 Pro Tip: Avoid blocking code and keep edge functions lean.
← Back to Web Frameworks | Browse all categories | View all cheat sheets