Component Discovery in Nuxt.js
Last Updated :
04 Apr, 2022
In this article, we are going to learn how component discovery works in NuxtJs. Nuxt.js is a free and open-source web application framework based on Vue.js, Node.js, Webpack, and Babel.js. Nuxt is inspired by Next.js, which is a framework of a similar purpose, based on React.js.
Create NuxtJS Application:
Step 1: You can create a new NuxtJs project using the below command:
npx create-nuxt-app gfg
Step 2: Now navigate to your app using the following command:
cd gfg
Project Structure: It will look like this.

Importing Components: In Nuxt.Js you don't have to manually import the components. You can just add the component in the components folder and Nuxt.Js will do the work for you.
Example: Now let's create a new component in the components folder with the name 'Data.vue' and with the below content.
Data.vue
<template>
<div>
<h5>This is the Data Component - GeeksforGeeks</h5>
</div>
</template>
index.vue: Now let's use the component on the homepage. Add the below code in the index.vue file.
index.vue
<template>
<div>
<h3>This is the Home Page - GeeksforGeeks</h3>
<Data/>
</div>
</template>
Start the application: Run the application using the below code.
npm run dev
Output:

Importing Nested Component: You can also import nested components by changing the name of the component while using.
Example: let's create a new file with the name 'file' in the component directory, and inside that let's create a new component with the name 'Demo.vue' and with the below content.
Demo.vue
<template>
<div>
<h5>This is the Demo - GeeksforGeeks</h5>
</div>
</template>
- index.vue: Now change the content odex.vue file.
index.vue
<template>
<div>
<h3>This is the Home Page - GeeksforGeeks</h3>
<fileDemo/>
</div>
</template>
Start the application: Run the application using the below code.
npm run dev
Output:

Similar Reads
Next.js Components Next.js components are integral to building modular and efficient applications, offering tools like Image, Link, Script, and Font to handle media, navigation, scripts, and typography effectively. These components enhance performance and streamline development in Next.js.Table of ContentWhat is a Com
4 min read
Vue.js Dynamic Components Vue.js is a progressive javascript framework for developing web user interfaces. It is a performant, approachable, and versatile framework. We can create Single Page Applications as well as Full Stack applications. It is built on top of HTML, CSS, and Javascript which makes it easier for developers
3 min read
What is Link component in Next.js ? In Next.js, Link is used to create links between pages in a Next.js app. To create a link, insert the <Link> component into your page, and specify the path to the page you want to link to. Â Link ComponentThe Link component in Next.js is a built-in feature that provides client-side navigation b
2 min read
How to create components in ReactJS ? Components in React JS is are the core of building React applications. Components are the building blocks that contains UI elements and logic, making the development process easier and reusable. In this article we will see how we can create components in React JS. Table of Content React Functional C
3 min read
Next.js Client Components Next.js, a popular React framework, has seen significant growth in recent years due to its robust features for building modern web applications. One of the key concepts introduced in Next.js is the distinction between Server and Client Components. In this article, we'll focus on Client Components an
4 min read