Vue.js / Nuxt.js

Nuxt Fundamentals

Nuxt structure, pages directory, auto-routing, layouts, app.vue, server directory, nuxt.config

22 interview questions·
Mid-Level
1

What is the minimum required structure for a Nuxt 3 application?

Answer

A Nuxt 3 application requires only an app.vue file or a pages/ directory at the project root. If app.vue exists without a pages/ folder, Nuxt creates an application without Vue Router. If pages/ exists, Nuxt automatically enables file-based routing and requires <NuxtPage /> in app.vue to display routes.

2

How does automatic routing work in the pages/ directory?

Answer

Nuxt's pages/ directory uses file-based routing: each .vue file automatically creates a corresponding route. For example, pages/index.vue becomes the '/' route, pages/about.vue becomes '/about', and pages/blog/[id].vue creates a dynamic route '/blog/:id'. This approach eliminates manual router configuration.

3

What is the role of the <NuxtPage /> component in app.vue?

Answer

The <NuxtPage /> component is an outlet that displays the active page content based on the current route. It is mandatory in app.vue when the pages/ directory exists. Without <NuxtPage />, routes will not be displayed. It is equivalent to <router-view /> in standard Vue Router but adapted for Nuxt.

4

How to apply a specific layout to a page in Nuxt 3?

5

What is the difference between using <NuxtLayout> in app.vue and not using it?

+19 interview questions

Master Vue.js / Nuxt.js for your next interview

Access all questions, flashcards, technical tests, code review exercises and interview simulators.

Start for free