Create new next.js project

Make sure I use latest Node.js and React.

npx create-next-app

npm run dev   // Run dev server
npm run build // Run build
npm run start // Run build server (production result)

Middleware (in Next.js 12)

When a visitor sends a request, the middleware runs its own code first, before it forwards it to the actual code.

Screen Shot 2022-08-03 at 10.37.13.png

I can add my own middleware in next.js by adding a file called pages/_middleware.js

Things like: