This demo shows example of how middleware works in Nuxt
Nuxt offers middleware both for client side and server side. Client side middlewares can be bound to certain components via definePageMeta
or can run before each routing event thanks to *.global.ts
filename. Server middlewares are being executed before each server API call.
git checkout demos-nuxt project
cd nuxt-middlware
pnpm install
pnpm dev
localhost:3000
The behavior of each middleware is demonstrated by the log messages in the browser console (F12). Navigate through the app and interact with the UI to see what is happening when.