Nuxt.js
Nuxt is to Vue what Next is to React: file-based pages, auto-imports, Nitro server routes and a rendering mode per route. Interviewers go here once SSR, SEO or a BFF comes up.
on this pageshowhide
explore
- File-Based Routing5 questions
- Rendering Modes5 questions
- Auto-Imports & Composables5 questions
- Data Fetching6 questions
- Server Routes & Nitro6 questions
- Modules & Config6 questions
questions
page 2 of 2In Nuxt 4, server middleware sets `event.context.warehouse` from a cookie and a `defineCachedEventHandler` route reads it. Why does every shopper then see the first shopper's stock, and how do you fix it?
basics
~20 sThe cached handler's key comes from the URL and varies headers only, while event.context passes through unkeyed, so the first shopper's warehouse is cached for everyone. Put the warehouse into the key, or cache just the upstream call per warehouse.
In Nuxt 4, when does code in `server/middleware/` run compared with code in `server/plugins/`, and what happens if a server middleware returns a value?
basics
~20 sServer middleware runs on every request Nitro routes, before the route handler, and should only add context, set headers or throw; a returned value becomes the response and stops the request. Nitro plugins run once per server start to register hooks.
In Nuxt 4, what does Nitro's `useStorage()` give a server route, and where does that data live in development versus a production deployment?
basics
~20 suseStorage() returns Nitro's key-value storage, with getItem, setItem, removeItem and getKeys over named mount points. In development the data and cache mounts are folders on disk; in production anything unconfigured is in memory, except the data mount on Node presets.
showing 31–33 of 33