All interview guides

Nuxt.js Interview Questions and Answers

24 questions that come up in Nuxt.js technical interviews, each with the answer and an explanation of why it is right.

Test yourself — 90 question bank

1. What is Nuxt.js?

Beginner

Answer: Framework built on Vue.js for production-ready apps

Nuxt.js is an intuitive Vue framework for building production-ready web applications with features like SSR, SSG, file-based routing, and automatic code splitting.

2. What is useFetch()?

Intermediate

Answer: Composable for data fetching with SSR support

useFetch() fetches data with SSR support, caching, reactivity. const { data, pending, error } = await useFetch('/api/data'). Auto-handles request deduplication.

3. What is Nitro server engine?

Advanced

Answer: Universal server engine powering Nuxt server

Nitro is universal server engine in Nuxt 3. Provides API routes, SSR, file-based routing, zero-config. Supports multiple deployment targets. Optimized, minimal.

4. What are Nitro presets?

Advanced

Answer: Deployment configurations for different platforms

Nitro presets configure builds for platforms: node, vercel, netlify, cloudflare. Set in nuxt.config.ts nitro.preset. Auto-detects from environment.

5. What are the main rendering modes in Nuxt 3?

Beginner

Answer: SSR, SSG, SPA

Nuxt 3 supports Server-Side Rendering (SSR), Static Site Generation (SSG), and Single Page Application (SPA) modes. Can mix modes per route.

6. What is useAsyncData()?

Intermediate

Answer: Composable for async data with custom fetching

useAsyncData('key', () => fetchData()) for custom async operations. More flexible than useFetch. Supports any async function. Must provide unique key.

7. What is server middleware in Nuxt?

Advanced

Answer: Middleware running on Nitro server

Server middleware in server/middleware/ runs on all requests. Use for logging, auth, headers. Export event handler. Runs before API routes.

8. What is the difference between useFetch and useAsyncData?

Intermediate

Answer: useFetch is shorthand for useAsyncData with $fetch

useFetch is convenience wrapper around useAsyncData + $fetch. Use useFetch for simple fetching, useAsyncData for complex logic or non-fetch operations.

9. How do you create a page in Nuxt?

Beginner

Answer: Create .vue file in pages/ directory

Create .vue file in pages/ directory. Nuxt automatically generates routes based on file structure. No manual route configuration needed for basic routes.

10. What is file-based routing?

Beginner

Answer: Routes automatically generated from pages/ directory structure

File-based routing auto-generates routes from pages/ directory structure. pages/index.vue → /, pages/about.vue → /about. Convention over configuration.

11. What is route caching?

Advanced

Answer: Caches rendered routes with routeRules

Route caching with routeRules: { '/blog/**': { swr: 3600 } }. Stale-while-revalidate, cache strategies. Hybrid rendering feature. Improves performance.

12. What is lazy data fetching?

Intermediate

Answer: Non-blocking data fetching with useLazyFetch

useLazyFetch() and useLazyAsyncData() don't block navigation. Component renders immediately, data loads in background. Good for non-critical data.

13. What is Nuxt Island?

Advanced

Answer: Selective hydration for components

Nuxt Island enables selective hydration. Use <NuxtIsland name="component">. Component hydrates independently. Experimental. Improves performance for static parts.

14. How do you create a dynamic route?

Beginner

Answer: Use square brackets: [id].vue

Create dynamic routes with square brackets: pages/users/[id].vue → /users/:id. Access param with useRoute().params.id. Supports nested dynamics.

15. What is middleware?

Intermediate

Answer: Code running before route navigation

Middleware runs before navigation. Define in middleware/ directory. Types: anonymous (inline), named (middleware/auth.ts), global (middleware/auth.global.ts).

16. What is a layout in Nuxt?

Beginner

Answer: Wrapper component for pages

Layout is a wrapper component for pages. Define in layouts/ directory. Default layout is layouts/default.vue. Switch layouts with definePageMeta({ layout: 'custom' }).

17. How do you create named middleware?

Intermediate

Answer: Export default defineNuxtRouteMiddleware() from middleware/

Create middleware/auth.ts: export default defineNuxtRouteMiddleware((to, from) => {}). Apply with definePageMeta({ middleware: 'auth' }). Access route, context.

18. What is payload extraction?

Advanced

Answer: Separates data from HTML for optimized transfers

Payload extraction separates JSON data from HTML. Reduces HTML size, improves caching. Automatic in Nuxt 3. Separate _payload.json files. Experimental feature.

19. What is code splitting?

Advanced

Answer: Automatically splits code into chunks

Code splitting divides code into smaller chunks. Automatic per page, component. Lazy-load with defineAsyncComponent. Improves initial load. Configure chunk strategy.

20. What is global middleware?

Intermediate

Answer: Middleware running on every route

Global middleware runs on every route. Name file with .global.ts suffix: middleware/auth.global.ts. No need to register per page. Use sparingly for performance.

21. How do you set a custom layout for a page?

Beginner

Answer: definePageMeta({ layout: 'name' })

Use definePageMeta({ layout: 'custom' }) in script setup. Layout file must exist in layouts/custom.vue. Can disable layout with layout: false.

22. What is a plugin?

Intermediate

Answer: Code running when creating Vue app

Plugins run when creating app. Define in plugins/ directory. Use for Vue plugins, provide/inject, error handlers. Auto-registered. Support both server/client.

23. What is tree shaking?

Advanced

Answer: Removes unused code from bundles

Tree shaking removes unused exports. Automatic with Vite. Use ES modules, avoid side effects. Configure in build options. Significant bundle size reduction.

24. What is nuxt.config.ts?

Beginner

Answer: Main configuration file for Nuxt app

nuxt.config.ts is the main configuration file. Configure modules, build options, runtime config, app settings, head meta, CSS, etc. Uses defineNuxtConfig().

Ready to test yourself?

The full Nuxt.js bank has 90 questions across 3 difficulty levels — timed, shuffled, and scored.

Take the Nuxt.js quiz