Catalog / Nuxt.js Cheat Sheet
Nuxt.js Cheat Sheet
A comprehensive cheat sheet covering essential Nuxt.js concepts, configurations, components, and deployment strategies for building universal Vue.js applications.
Nuxt.js Fundamentals
Project Setup
Create a new Nuxt.js project:
Follow the prompts to configure your project (e.g., UI framework, modules). |
Navigate to the project directory:
|
Run the development server:
|
Directory Structure
|
Contains the application’s routes/views. Each |
|
Defines the application’s layout. |
|
Reusable Vue components. |
|
Vuex store files (state management). |
|
Main configuration file for Nuxt.js. |
|
Files served directly (e.g., |
Key Concepts
Automatic Routing: Nuxt.js automatically generates routes based on the files in the |
Server-Side Rendering (SSR): Nuxt.js renders Vue components on the server before sending them to the client, improving SEO and initial load time. |
Single Page Application (SPA): Nuxt.js can also be configured as a SPA application, creating only client side rendered apps. |
Vuex Integration: Seamless integration with Vuex for state management. |
Middleware: Custom functions that run before rendering a page. Useful for authentication, etc. |
Modules: Extend Nuxt.js core functionality with pre-built modules (e.g., |
Routing & Pages
Basic Routing
Create
|
Use the
|
Dynamic Routes
Create dynamic routes using a leading underscore in the filename.
|
Access the dynamic route parameter using
|
Programmatic Navigation
Use
|
Navigate with a named route:
|
Navigate with parameters:
|
Middleware in Pages
Define middleware in your page component:
|
Create middleware files in the
|
Layouts & Components
Layouts
Create layouts in the
|
Use
|
Define a custom layout for a page:
|
Components
Create reusable components in the |
Import and use components in your pages and layouts.
|
Head Management
Manage the document
|
Data Fetching & API
Async Data
Use the
|
|
Fetch Hook
Use the
|
Nuxt Axios Module
The Install:
|
Add it to
|
Use
|