skip to content

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 pageshow

explore

questions

page 2 of 2

In 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?

level: seniorimportance: should knowfreq 24%

basics

~20 s

The 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.

open as a page

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?

level: seniorimportance: should knowfreq 29%

basics

~20 s

Server 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.

open as a page

In Nuxt 4, what does Nitro's `useStorage()` give a server route, and where does that data live in development versus a production deployment?

level: middleimportance: nice to knowfreq 20%

basics

~20 s

useStorage() 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.

open as a page

showing 31–33 of 33