url stringlengths 24 106 | html stringlengths 41 53k | title stringlengths 0 63 |
|---|---|---|
https://nuxt.com/docs/examples/routing/pages | Examples
Routing
Pages
This example shows how to use the pages/ directory to create application routes.
Read more in Docs > Guide > Directory Structure > Pages.
Loading Sandbox...
Middleware
This example shows how to add route middleware with the middleware/ directory or with a plugin, and how to use them globally... | Pages · Nuxt Examples |
https://nuxt.com/docs/examples/features/layouts | Examples
Features
Layouts
This example shows how to define default and custom layouts.
Read more in Docs > Getting Started > Views #layouts.
Read more in Docs > Guide > Directory Structure > Layouts.
Loading Sandbox...
Meta Tags
This example shows how to use the Nuxt helpers and composables for SEO and meta manag... | Layouts · Nuxt Examples |
https://nuxt.com/docs/examples/routing/middleware | Examples
Routing
Middleware
This example shows how to add route middleware with the middleware/ directory or with a plugin, and how to use them globally or per page.
Read more in Docs > Guide > Directory Structure > Middleware.
Loading Sandbox...
Layouts
This example shows how to define default and custom layouts.... | Middleware · Nuxt Examples |
https://nuxt.com/docs/examples/features/meta-tags | Examples
Features
Meta Tags
This example shows how to use the Nuxt helpers and composables for SEO and meta management.
Read more in Docs > Getting Started > Seo Meta.
Loading Sandbox...
State Management
This example shows how to use the `useState` composable to create a reactive and SSR-friendly shared state acro... | Meta Tags · Nuxt Examples |
https://nuxt.com/docs/examples/features/auto-imports | Examples
Features
Auto Imports
This example demonstrates the auto-imports feature in Nuxt.
Example of the auto-imports feature in Nuxt with:
Vue components in the components/ directory are auto-imported and can be used directly in your templates.
Vue composables in the composables/ directory are auto-imported and ca... | Auto Imports · Nuxt Examples |
https://nuxt.com/docs/examples/features/state-management | Examples
Features
State Management
This example shows how to use the `useState` composable to create a reactive and SSR-friendly shared state across components.
Read more in Docs > Getting Started > State Management.
Read more in Docs > API > Composables > Use State.
Loading Sandbox...
Data Fetching
This example ... | State Management · Nuxt Examples |
https://nuxt.com/docs/api/nuxt-config#imports | Nuxt Configuration
Discover all the options you can use in your nuxt.config.ts file.
This file is auto-generated from Nuxt source code.
_build
Type: boolean
Default: false
_cli
Type: boolean
Default: false
_generate
Type: boolean
Default: false
_installedModules
Type: array
_legacyGenerate
Type: boolean
Default: fals... | Nuxt Configuration |
https://nuxt.com/docs/examples/features/data-fetching | Examples
Features
Data Fetching
This example demonstrates data fetching with Nuxt 3 using built-in composables and API routes.
Read more in Docs > Getting Started > Data Fetching.
Read more in Docs > Guide > Directory Structure > Server.
Loading Sandbox...
Auto Imports
This example demonstrates the auto-imports f... | Data Fetching · Nuxt Examples |
https://nuxt.com/docs/api/composables/use-nuxt-app | Composables
useNuxtApp
Source
Access the shared runtime context of the Nuxt Application.
useNuxtApp is a built-in composable that provides a way to access shared runtime context of Nuxt, which is available on both client and server side. It helps you access the Vue app instance, runtime hooks, runtime config variable... | useNuxtApp · Nuxt Composables |
https://nuxt.com/docs/examples/hello-world | Examples
Hello World
A minimal Nuxt 3 application only requires the `app.vue` and `nuxt.config.js` files.
Read more in Docs > Getting Started > Introduction.
Loading Sandbox...
Modules
Learn how to migrate from Nuxt 2 to Nuxt 3 modules.
Auto Imports
This example demonstrates the auto-imports feature in Nuxt. | Hello World · Nuxt Examples |
https://nuxt.com/docs/guide/concepts/auto-imports | Guide
Key Concepts
Auto-imports
Nuxt auto-imports components, composables, helper functions and Vue APIs.
Nuxt auto-imports components, composables and Vue.js APIs to use across your application without explicitly importing them.
app.vue
<script setup lang="ts">
const count = ref(1) // ref is auto-imported
</scrip... | Auto-imports · Nuxt Concepts |
https://nuxt.com/docs/guide/going-further/custom-routing | Guide
Going Further
Custom Routing
In Nuxt 3, your routing is defined by the structure of your files inside the pages directory. However, since it uses vue-router under the hood, Nuxt offers you several ways to add custom routes in your project.
Adding custom routes
In Nuxt 3, your routing is defined by the structur... | Custom Routing · Nuxt Advanced |
https://nuxt.com/docs/guide/going-further/nightly-release-channel | Guide
Going Further
Nightly Release Channel
The nightly release channel allows using Nuxt built directly from the latest commits to the repository.
Nuxt lands commits, improvements, and bug fixes every day. You can opt in to test them earlier before the next release.
After a commit is merged into the main branch of ... | Nightly Release Channel · Nuxt Advanced |
https://nuxt.com/docs/guide/going-further/runtime-config | Guide
Going Further
Runtime Config
Nuxt provides a runtime config API to expose configuration and secrets within your application.
Exposing
To expose config and environment variables to the rest of your app, you will need to define runtime configuration in your nuxt.config file, using the runtimeConfig option.
nuxt... | Runtime Config · Nuxt Advanced |
https://nuxt.com/docs/guide/going-further/debugging | Guide
Going Further
Debugging
In Nuxt 3, you can get started with debugging your application directly in the browser as well as in your IDE.
Sourcemaps
Sourcemaps are enabled for your server build by default, and for the client build in dev mode, but you can enable them more specifically in your configuration.
expo... | Debugging · Nuxt Advanced |
https://nuxt.com/docs/guide/going-further/layers | Guide
Going Further
Authoring Nuxt Layers
Nuxt provides a powerful system that allows you to extend the default files, configs, and much more.
Nuxt layers are a powerful feature that you can use to share and reuse partial Nuxt applications within a monorepo, or from a git repository or npm package. The layers structu... | Authoring Nuxt Layers · Nuxt Advanced |
https://nuxt.com/docs/guide/going-further/nuxt-app | Guide
Going Further
NuxtApp
Source
In Nuxt 3, you can access runtime app context within composables, components and plugins.
In Nuxt 3, you can access runtime app context within composables, components and plugins.
In Nuxt 2, this was referred to as Nuxt context.
Nuxt App Interface
Jump over the NuxtApp interface do... | NuxtApp · Nuxt Advanced |
https://nuxt.com/docs/guide/going-further/kit | Guide
Going Further
Nuxt Kit
@nuxt/kit provides features for module authors.
Nuxt Kit provides composable utilities to make interacting with Nuxt Hooks, the Nuxt Interface and developing Nuxt Modules super easy.
Discover all Nuxt Kit utilities.
Usage
Install Dependency
You can install the latest Nuxt Kit by adding ... | Nuxt Kit · Nuxt Advanced |
https://nuxt.com/docs/guide/going-further/hooks | Guide
Going Further
Lifecycle Hooks
Nuxt provides a powerful hooking system to expand almost every aspect using hooks.
The hooking system is powered by unjs/hookable.
Nuxt Hooks (Build Time)
These hooks are available for Nuxt Modules and build context.
Within nuxt.config
nuxt.config
export default defineNuxtConfig(... | Lifecycle Hooks · Nuxt Advanced |
https://nuxt.com/docs/guide/going-further/internals | Guide
Going Further
How Nuxt Works?
Nuxt is a minimal but highly customizable framework to build web applications.
This guide helps you better understand Nuxt internals to develop new solutions and module integrations on top of Nuxt.
The Nuxt Interface
When you start Nuxt in development mode with nuxi dev or buildi... | How Nuxt Works? · Nuxt Advanced |
https://nuxt.com/docs/guide/directory-structure/tsconfig | Guide
Directory Structure
tsconfig.json
Nuxt generates a .nuxt/tsconfig.json file with sensible defaults and your aliases.
Nuxt automatically generates a .nuxt/tsconfig.json file with the resolved aliases you are using in your Nuxt project, as well as with other sensible defaults.
You can benefit from this by creati... | tsconfig.json · Nuxt Directory Structure |
https://nuxt.com/docs/guide/going-further/experimental-features | Guide
Going Further
Experimental Features
Enable Nuxt experimental features to unlock new possibilities.
The Nuxt experimental features can be enabled in the Nuxt configuration file.
Internally, Nuxt uses @nuxt/schema to define these experimental features. You can refer to the API documentation or the source code fo... | Experimental Features · Nuxt Advanced |
https://nuxt.com/docs/guide/directory-structure/package | Guide
Directory Structure
package.json
The package.json file contains all the dependencies and scripts for your application.
The minimal package.json of your Nuxt application should looks like:
package.json
{
"name": "nuxt-app",
"private": true,
"type": "module",
"scripts": {
"build": "nuxt build",
... | package.json · Nuxt Directory Structure |
https://nuxt.com/docs/guide/directory-structure/app | Guide
Directory Structure
app.vue
The app.vue file is the main component of your Nuxt application.
Minimal Usage
With Nuxt 3, the pages/ directory is optional. If not present, Nuxt won't include vue-router dependency. This is useful when working on a landing page or an application that does not need routing.
app.vu... | app.vue · Nuxt Directory Structure |
https://nuxt.com/docs/guide/directory-structure/nuxtignore | Guide
Directory Structure
.nuxtignore
The .nuxtignore file lets Nuxt ignore files in your project’s root directory during the build phase.
The .nuxtignore file tells Nuxt to ignore files in your project’s root directory (rootDir) during the build phase.
It is subject to the same specification as .gitignore and .esli... | .nuxtignore · Nuxt Directory Structure |
https://nuxt.com/docs/guide/directory-structure/app-config | Guide
Directory Structure
app.config.ts
Expose reactive configuration within your application with the App Config file.
Nuxt 3 provides an app.config config file to expose reactive configuration within your application with the ability to update it at runtime within lifecycle or using a nuxt plugin and editing it wit... | app.config.ts · Nuxt Directory Structure |
https://nuxt.com/docs/guide/directory-structure/gitignore | Guide
Directory Structure
.gitignore
A .gitignore file specifies intentionally untracked files that git should ignore.
A .gitignore file specifies intentionally untracked files that git should ignore.
Read more in the git documentation.
We recommend having a .gitignore file that has at least the following entries ... | .gitignore · Nuxt Directory Structure |
https://nuxt.com/docs/guide/directory-structure/env | Guide
Directory Structure
.env
A .env file specifies your build/dev-time environment variables.
This file should be added to your .gitignore file to avoid pushing secrets to your repository.
Dev, Build and Generate Time
Nuxt CLI has built-in dotenv support in development mode and when running nuxi build and nuxi gen... | .env · Nuxt Directory Structure |
https://nuxt.com/docs/guide/directory-structure/utils | Guide
Directory Structure
utils
Use the utils/ directory to auto-import your utility functions throughout your application.
The main purpose of the utils/ directory is to allow a semantic distinction between your Vue composables and other auto-imported utility functions.
Usage
Method 1: Using named export
utils/in... | utils/ · Nuxt Directory Structure |
https://nuxt.com/docs/guide/directory-structure/server | Guide
Directory Structure
server
The server/ directory is used to register API and server handlers to your application.
Nuxt automatically scans files inside these directories to register API and server handlers with Hot Module Replacement (HMR) support.
Directory structure
-| server/
---| api/
-----| hello.ts ... | server/ · Nuxt Directory Structure |
https://nuxt.com/docs/guide/directory-structure/node_modules | Guide
Directory Structure
node_modules
The package manager stores the dependencies of your project in the node_modules/ directory.
The package manager (npm or yarn or pnpm or bun) creates this directory to store the dependencies of your project.
This directory should be added to your .gitignore file to avoid pushing... | node_modules/ · Nuxt Directory Structure |
https://nuxt.com/docs/guide/directory-structure/public | Guide
Directory Structure
public
The public/ directory is used to serve your website's static assets.
Files contained within the public/ directory are served at the root and are not modified by the build process. This is suitable for files that have to keep their names (e.g. robots.txt) or likely won't change (e.g. f... | public/ · Nuxt Directory Structure |
https://nuxt.com/docs/guide/directory-structure/plugins | Guide
Directory Structure
plugins
Nuxt has a plugins system to use Vue plugins and more at the creation of your Vue application.
Nuxt automatically reads the files in the plugins/ directory and loads them at the creation of the Vue application.
All plugins inside are auto-registered, you don't need not add them to y... | plugins/ · Nuxt Directory Structure |
https://nuxt.com/docs/guide/directory-structure/modules | Guide
Directory Structure
modules
Use the modules/ directory to automatically register local modules within your application.
It is a good place to place any local modules you develop while building your application.
The auto-registered files patterns are:
modules/*/index.ts
modules/*.ts
You don't need to add thos... | modules/ · Nuxt Directory Structure |
https://nuxt.com/docs/guide/directory-structure/middleware | Guide
Directory Structure
middleware
Nuxt provides middleware to run code before navigating to a particular route.
Nuxt provides a customizable route middleware framework you can use throughout your application, ideal for extracting code that you want to run before navigating to a particular route.
There are three k... | middleware/ · Nuxt Directory Structure |
https://nuxt.com/docs/guide/directory-structure/composables | Guide
Directory Structure
composables
Use the composables/ directory to auto-import your Vue composables into your application.
Usage
Method 1: Using named export
composables/useFoo.ts
export const useFoo = () => {
return useState('foo', () => 'bar')
}
Method 2: Using default export
composables/use-foo.ts or... | composables/ · Nuxt Directory Structure |
https://nuxt.com/docs/guide/directory-structure/content | Guide
Directory Structure
content
Use the content/ directory to create a file-based CMS for your application.
Nuxt Content reads the content/ directory in your project and parses .md, .yml, .csv and .json files to create a file-based CMS for your application.
Render your content with built-in components.
Query your ... | content/ · Nuxt Directory Structure |
https://nuxt.com/docs/guide/directory-structure/layouts | Guide
Directory Structure
layouts
Nuxt provides a layouts framework to extract common UI patterns into reusable layouts.
For best performance, components placed in this directory will be automatically loaded via asynchronous import when used.
Enable Layouts
Layouts are enabled by adding <NuxtLayout> to your app.vue:... | layouts/ · Nuxt Directory Structure |
https://nuxt.com/docs/guide/directory-structure/components | Guide
Directory Structure
components
The components/ directory is where you put all your Vue components.
Nuxt automatically imports any components in this directory (along with components that are registered by any modules you may be using).
Directory Structure
| components/
--| AppHeader.vue
--| AppFooter.vue
ap... | components/ · Nuxt Directory Structure |
https://nuxt.com/docs/guide/concepts/typescript | Guide
Key Concepts
TypeScript
Nuxt 3 is fully typed and provides helpful shortcuts to ensure you have access to accurate type information when you are coding.
Type-checking
By default, Nuxt doesn't check types when you run nuxi dev or nuxi build, for performance reasons.
To enable type-checking at build or developm... | TypeScript · Nuxt Concepts |
https://nuxt.com/docs/guide/directory-structure/assets | Guide
Directory Structure
assets
The assets/ directory is used to add all the website's assets that the build tool will process.
The directory usually contains the following types of files:
Stylesheets (CSS, SASS, etc.)
Fonts
Images that won't be served from the public/ directory.
If you want to serve assets from t... | assets/ · Nuxt Directory Structure |
https://nuxt.com/docs/guide/directory-structure/output | Guide
Directory Structure
.output
Nuxt creates the .output/ directory when building your application for production.
This directory should be added to your .gitignore file to avoid pushing the build output to your repository.
Use this directory to deploy your Nuxt application to production.
Read more in Docs > Get... | .output/ · Nuxt Directory Structure |
https://nuxt.com/docs/guide/directory-structure/nuxt | Guide
Directory Structure
.nuxt
Nuxt uses the .nuxt/ directory in development to generate your Vue application.
This directory should be added to your .gitignore file to avoid pushing the dev build output to your repository.
This directory is interesting if you want to learn more about the files Nuxt generates based... | .nuxt/ · Nuxt Directory Structure |
https://nuxt.com/docs/guide/concepts/vuejs-development | Guide
Key Concepts
Vue.js Development
Nuxt uses Vue.js and adds features such as component auto-imports, file-based routing and composables for a SSR-friendly usage.
Nuxt integrates Vue 3, the new major release of Vue that enables new patterns for Nuxt users.
While an in-depth knowledge of Vue is not required to use... | Vue.js Development · Nuxt Concepts |
https://nuxt.com/docs/guide/concepts/esm | Guide
Key Concepts
ES Modules
Nuxt 3 (and Bridge) uses Native ES Modules.
This guide helps explain what ES Modules are and how to make a Nuxt app (or upstream library) compatible with ESM.
Background
CommonJS Modules
CommonJS (CJS) is a format introduced by Node.js that allows sharing functionality between isolated... | ES Modules · Nuxt Concepts |
https://nuxt.com/docs/guide/concepts/auto-imports | Guide
Key Concepts
Auto-imports
Nuxt auto-imports components, composables, helper functions and Vue APIs.
Nuxt auto-imports components, composables and Vue.js APIs to use across your application without explicitly importing them.
app.vue
<script setup lang="ts">
const count = ref(1) // ref is auto-imported
</scrip... | Auto-imports · Nuxt Concepts |
https://nuxt.com/docs/guide/concepts/rendering | Guide
Key Concepts
Rendering Modes
Learn about the different rendering modes available in Nuxt.
Nuxt supports different rendering modes, universal rendering, client-side rendering but also offers hybrid-rendering and the possibility to render your application on CDN Edge Servers.
Both the browser and server can inte... | Rendering Modes · Nuxt Concepts |
https://nuxt.com/docs/guide/concepts/modules | Guide
Key Concepts
Modules
Nuxt provides a module system to extend the framework core and simplify integrations.
Exploring Nuxt Modules
When developing production-grade applications with Nuxt you might find that the framework's core functionality is not enough. Nuxt can be extended with configuration options and plu... | Modules · Nuxt Concepts |
https://nuxt.com/docs/guide/concepts/server-engine | Guide
Key Concepts
Server Engine
Nuxt 3 is powered by a new server engine: Nitro.
While building Nuxt 3, we created a new server engine: Nitro.
It is shipped with many features:
Cross-platform support for Node.js, Browsers, service-workers and more.
Serverless support out-of-the-box.
API routes support.
Automatic c... | Server Engine · Nuxt Concepts |
https://nuxt.com/docs/getting-started/testing | Get Started
Testing
How to test your Nuxt application.
Test utils are still in development and the API and behavior may change. Currently, it is in preview stage but not yet ready for testing production apps. If you are a module author, you can find more specific information in the Module Author's guide
In Nuxt 3, w... | Testing · Get Started with Nuxt |
https://nuxt.com/docs/getting-started/upgrade | Get Started
Upgrade Guide
Learn how to upgrade to the latest Nuxt version.
Upgrading Nuxt 3
Latest release
To upgrade Nuxt 3 to the latest release, use the nuxi upgrade command.
Terminal
npx nuxi upgrade
Nightly Release Channel
To use the latest Nuxt 3 build and test features before their release, read about the ... | Upgrade Guide · Get Started with Nuxt |
https://nuxt.com/docs/getting-started/deployment | Get Started
Deployment
Learn how to deploy your Nuxt application to any hosting provider.
A Nuxt application can be deployed on a Node.js server, pre-rendered for static hosting, or deployed to serverless or edge (CDN) environments.
If you are looking for a list of cloud providers that support Nuxt 3, see the Hostin... | Deployment · Get Started with Nuxt |
https://nuxt.com/docs/getting-started/transitions | Get Started
Transitions
Apply transitions between pages and layouts with Vue or native browser View Transitions.
Nuxt leverages Vue's <Transition> component to apply transitions between pages and layouts.
Page transitions
You can enable page transitions to apply an automatic transition for all your pages.
nuxt.conf... | Transitions · Get Started with Nuxt |
https://nuxt.com/docs/getting-started/server | Get Started
Server
Build full-stack applications with Nuxt's server framework. You can fetch data from your database or another server, create APIs, or even generate static server-side content like a sitemap or a RSS feed - all from a single codebase.
Read more in Docs > Guide > Directory Structure > Server.
Powered... | Server · Get Started with Nuxt |
https://nuxt.com/docs/getting-started/layers | Get Started
Layers
Nuxt provides a powerful system that allows you to extend the default files, configs, and much more.
One of the core features of Nuxt 3 is the layers and extending support. You can extend a default Nuxt application to reuse components, utils, and configuration. The layers structure is almost identi... | Layers · Get Started with Nuxt |
https://nuxt.com/docs/getting-started/error-handling | Get Started
Error Handling
Learn how to catch and handle errors in Nuxt.
Nuxt 3 is a full-stack framework, which means there are several sources of unpreventable user runtime errors that can happen in different contexts:
Errors during the Vue rendering lifecycle (SSR & CSR)
Errors during Nitro server lifecycle (serv... | Error Handling · Get Started with Nuxt |
https://nuxt.com/docs/getting-started/state-management | Get Started
State Management
Nuxt provides powerful state management libraries and the useState composable to create a reactive and SSR-friendly shared state.
Nuxt provides the useState composable to create a reactive and SSR-friendly shared state across components.
useState is an SSR-friendly ref replacement. Its v... | State Management · Get Started with Nuxt |
https://nuxt.com/docs/getting-started/data-fetching | Get Started
Data fetching
Nuxt provides composables to handle data fetching within your application.
Nuxt comes with two composables and a built-in library to perform data-fetching in browser or server environments: useFetch, useAsyncData and $fetch.
In a nutshell:
useFetch is the most straightforward way to handle... | Data fetching · Get Started with Nuxt |
https://nuxt.com/docs/getting-started/seo-meta | Get Started
SEO and Meta
Improve your Nuxt app's SEO with powerful head config, composables and components.
Defaults
Out-of-the-box, Nuxt provides sane defaults, which you can override if needed.
nuxt.config.ts
export default defineNuxtConfig({
app: {
head: {
charset: 'utf-8',
viewport: 'width... | SEO and Meta · Get Started with Nuxt |
https://nuxt.com/docs/getting-started/styling | Get Started
Styling
Learn how to style your Nuxt application.
Nuxt is highly flexible when it comes to styling. Write your own styles, or reference local and external stylesheets. You can use CSS preprocessors, CSS frameworks, UI libraries and Nuxt modules to style your application.
Local Stylesheets
If you're writ... | Styling · Get Started with Nuxt |
https://nuxt.com/docs/getting-started/routing | Get Started
Routing
Nuxt file-system routing creates a route for every file in the pages/ directory.
One core feature of Nuxt is the file system router. Every Vue file inside the pages/ directory creates a corresponding URL (or route) that displays the contents of the file. By using dynamic imports for each page, Nux... | Routing · Get Started with Nuxt |
https://nuxt.com/docs/getting-started/assets | Get Started
Assets
Nuxt offers two options for your assets.
Nuxt uses two directories to handle assets like stylesheets, fonts or images.
The public/ directory content is served at the server root as-is.
The assets/ directory contains by convention every asset that you want the build tool (Vite or webpack) to proces... | Assets · Get Started with Nuxt |
https://nuxt.com/docs/getting-started/views | Get Started
Views
Nuxt provides several component layers to implement the user interface of your application.
app.vue
By default, Nuxt will treat this file as the entrypoint and render its content for every route of the application.
app.vue
<template>
<div>
<h1>Welcome to the homepage</h1>
</div>
</templ... | Views · Get Started with Nuxt |
https://nuxt.com/docs/getting-started/configuration | Get Started
Configuration
Nuxt is configured with sensible defaults to make you productive.
By default, Nuxt is configured to cover most use cases. The nuxt.config.ts file can override or extend this default configuration.
Nuxt Configuration
The nuxt.config.ts file is located at the root of a Nuxt project and can o... | Configuration · Get Started with Nuxt |
https://nuxt.com/docs/getting-started/installation | Get Started
Installation
Get started with Nuxt quickly with our online starters or start locally with your terminal.
Play Online
You can start playing with Nuxt 3 in your browser using our online sandboxes:
Open on StackBlitz
Open on CodeSandbox
Start with one of our starters and themes directly by opening nuxt.n... | Installation · Get Started with Nuxt |
https://nuxt.com/docs/community/getting-help | Community
Getting Help
We're a friendly community of developers and we'd love to help.
At some point, you may find that there's an issue you need some help with.
But don't worry! We're a friendly community of developers and we'd love to help.
"I can't figure out how to (...)."
You've read through these docs and yo... | Getting Help · Nuxt Community |
https://nuxt.com/docs/api/composables/use-app-config | Composables
useAppConfig
Source
Access the reactive app config defined in the project.
Usage
const appConfig = useAppConfig()
console.log(appConfig)
Read more in Docs > Guide > Directory Structure > App Config.
<Teleport>
The <Teleport> component teleports a component to a different location in the DOM.
useAs... | useAppConfig · Nuxt Composables |
https://nuxt.com/docs/examples/hello-world | Examples
Hello World
A minimal Nuxt 3 application only requires the `app.vue` and `nuxt.config.js` files.
Read more in Docs > Getting Started > Introduction.
Loading Sandbox...
Modules
Learn how to migrate from Nuxt 2 to Nuxt 3 modules.
Auto Imports
This example demonstrates the auto-imports feature in Nuxt. | Hello World · Nuxt Examples |
https://nuxt.com/docs/guide/concepts/auto-imports | Guide
Key Concepts
Auto-imports
Nuxt auto-imports components, composables, helper functions and Vue APIs.
Nuxt auto-imports components, composables and Vue.js APIs to use across your application without explicitly importing them.
app.vue
<script setup lang="ts">
const count = ref(1) // ref is auto-imported
</scrip... | Auto-imports · Nuxt Concepts |
https://nuxt.com/docs/getting-started/introduction | Get Started
Introduction
Nuxt's goal is to make web development intuitive and performant with a great Developer Experience in mind.
Nuxt is a free and open-source framework with an intuitive and extendable way to create type-safe, performant and production-grade full-stack web applications and websites with Vue.js.
... | Introduction · Get Started with Nuxt |
https://www.jsdocs.io/package/ofetch | A better fetch API. Works on node, browser and workers.
Index
Variables
$fetch
AbortController
fetch
Headers
ofetch
Functions
createFetch()
createFetchError()
Classes
FetchError
Interfaces
$Fetch
CreateFetchOptions
FetchContext
FetchError
FetchOptions
FetchResponse
IFetchError
SearchParameters
Type Aliases
FetchReques... | ofetch@1.3.3 - jsDocs.io |
https://www.typescriptlang.org/docs/handbook/classes.html | This page has been deprecated
This handbook page has been replaced, go to the new page
Go to new page
Classes
Traditional JavaScript uses functions and prototype-based inheritance to build up reusable components, but this may feel a bit awkward to programmers more comfortable with an object-oriented approach, where ... | TypeScript: Handbook - Classes |
https://www.typescriptlang.org/docs/handbook/declaration-files/templates/global-plugin-d-ts.html | Global: Plugin
UMD
A UMD module is one that can either be used as module (through an import), or as a global (when run in an environment without a module loader). Many popular libraries, such as Moment.js, are written this way. For example, in Node.js or using RequireJS, you would write:
import moment = require("mome... | TypeScript: Documentation - Global: Plugin |
https://www.typescriptlang.org/docs/handbook/generics.html#generic-types | This page has been deprecated
This handbook page has been replaced, go to the new page
Go to new page
Generics
A major part of software engineering is building components that not only have well-defined and consistent APIs, but are also reusable. Components that are capable of working on the data of today as well as... | TypeScript: Handbook - Generics |
https://www.typescriptlang.org/docs/handbook/declaration-files/templates.html | Templates
global-modifying-module.d.ts
global-plugin.d.ts
global.d.ts
module-class.d.ts
module-function.d.ts
module-plugin.d.ts
module.d.ts
On this page
Is this page helpful?
Yes
No
The TypeScript docs are an open source project. Help us improve these pages by sending a Pull Request ❤
Contributors to this page:
MH... | TypeScript: Documentation - Templates |
https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-3.html | TypeScript 4.3
Separate Write Types on Properties
In JavaScript, it’s pretty common for APIs to convert values that are passed in before storing them. This often happens with getters and setters too. For example, let’s imagine we’ve got a class with a setter that always converts a value into a number before saving it ... | TypeScript: Documentation - TypeScript 4.3 |
https://www.typescriptlang.org/docs/handbook/interfaces.html | This page has been deprecated
This handbook page has been replaced, go to the new page
Go to new page
Interfaces
One of TypeScript’s core principles is that type checking focuses on the shape that values have. This is sometimes called “duck typing” or “structural subtyping”. In TypeScript, interfaces fill the role o... | TypeScript: Handbook - Interfaces |
https://www.typescriptlang.org/docs/handbook/modules/introduction.html | Modules - Introduction
This document is divided into four sections:
The first section develops the theory behind how TypeScript approaches modules. If you want to be able to write the correct module-related compiler options for any situation, reason about how to integrate TypeScript with other tools, or understand ho... | TypeScript: Documentation - Modules - Introduction |
https://www.typescriptlang.org/docs/handbook/basic-types.html#a-note-about-let | This page has been deprecated
This handbook page has been replaced, go to the new page
Go to new page
Basic Types
For programs to be useful, we need to be able to work with some of the simplest units of data: numbers, strings, structures, boolean values, and the like. In TypeScript, we support the same types as you ... | TypeScript: Handbook - Basic Types |
https://www.typescriptlang.org/docs/handbook/functions.html#this-parameters | This page has been deprecated
This handbook page has been replaced, go to the new page
Go to new page
Functions
Functions are the fundamental building block of any application in JavaScript. They’re how you build up layers of abstraction, mimicking classes, information hiding, and modules. In TypeScript, while there... | TypeScript: Handbook - Functions |
https://www.typescriptlang.org/docs/handbook/nightly-builds.html | Nightly Builds
A nightly build from the TypeScript’s main branch is published by midnight PST to npm. Here is how you can get it and use it with your tools.
Using npm
npm install -D typescript@next
Updating your IDE to use the nightly builds
You can also update your editor/IDE to use the nightly drop. You will typic... | TypeScript: Documentation - Nightly Builds |
https://www.typescriptlang.org/docs/handbook/integrating-with-build-tools.html | Integrating with Build Tools
Babel
Install
npm install @babel/cli @babel/core @babel/preset-typescript --save-dev
.babelrc
{
"presets": ["@babel/preset-typescript"]
}
Using Command Line Interface
./node_modules/.bin/babel --out-file bundle.js src/index.ts
package.json
{
"scripts": {
"build": "babel --out-file b... | TypeScript: Documentation - Integrating with Build Tools |
https://www.typescriptlang.org/docs/handbook/configuring-watch.html | Configuring Watch
As of TypeScript 3.8 and onward, the Typescript compiler exposes configuration which controls how it watches files and directories. Prior to this version, configuration required the use of environment variables which are still available.
Background
The --watch implementation of the compiler relies ... | TypeScript: Documentation - Configuring Watch |
https://www.typescriptlang.org/docs/handbook/compiler-options.html | tsc CLI Options
Using the CLI
Running tsc locally will compile the closest project defined by a tsconfig.json, or you can compile a set of TypeScript files by passing in a glob of files you want. When input files are specified on the command line, tsconfig.json files are ignored.
# Run a compile based on a backwards ... | TypeScript: Documentation - tsc CLI Options |
https://www.typescriptlang.org/docs/handbook/project-references.html | Project References
Project references are a new feature in TypeScript 3.0 that allow you to structure your TypeScript programs into smaller pieces.
By doing this, you can greatly improve build times, enforce logical separation between components, and organize your code in new and better ways.
We’re also introducing ... | TypeScript: Documentation - Project References |
https://www.typescriptlang.org/docs/handbook/compiler-options-in-msbuild.html | Compiler Options in MSBuild
Overview
When you have an MSBuild based project which utilizes TypeScript such as an ASP.NET Core project, you can configure TypeScript in two ways. Either via a tsconfig.json or via the project settings.
Using a
tsconfig.json
We recommend using a tsconfig.json for your project when poss... | TypeScript: Documentation - Compiler Options in MSBuild |
https://www.typescriptlang.org/docs/handbook/declaration-files/dts-from-js.html | Creating .d.ts Files from .js files
With TypeScript 3.7, TypeScript added support for generating .d.ts files from JavaScript using JSDoc syntax.
This set up means you can own the editor experience of TypeScript-powered editors without porting your project to TypeScript, or having to maintain .d.ts files in your codeb... | TypeScript: Documentation - Creating .d.ts Files from .js files |
https://www.typescriptlang.org/docs/handbook/tsconfig-json.html | What is a tsconfig.json
Overview
The presence of a tsconfig.json file in a directory indicates that the directory is the root of a TypeScript project. The tsconfig.json file specifies the root files and the compiler options required to compile the project.
JavaScript projects can use a jsconfig.json file instead, whi... | TypeScript: Documentation - What is a tsconfig.json |
https://www.typescriptlang.org/docs/handbook/jsdoc-supported-types.html | JSDoc Reference
The list below outlines which constructs are currently supported when using JSDoc annotations to provide type information in JavaScript files.
Note any tags which are not explicitly listed below (such as @async) are not yet supported.
Types
@type
@param (or @arg or @argument)
@returns (or @return)
@t... | TypeScript: Documentation - JSDoc Reference |
https://www.typescriptlang.org/docs/handbook/type-checking-javascript-files.html | Type Checking JavaScript Files
Here are some notable differences on how checking works in .js files compared to .ts files.
Properties are inferred from assignments in class bodies
ES2015 does not have a means for declaring properties on classes. Properties are dynamically assigned, just like object literals.
In a .... | TypeScript: Documentation - Type Checking JavaScript Files |
https://www.typescriptlang.org/docs/handbook/declaration-files/consumption.html | Consumption
Downloading
Getting type declarations requires no tools apart from npm.
As an example, getting the declarations for a library like lodash takes nothing more than the following command
npm install --save-dev @types/lodash
It is worth noting that if the npm package already includes its declaration file as... | TypeScript: Documentation - Consumption |
https://www.typescriptlang.org/docs/handbook/declaration-files/publishing.html | Publishing
Now that you have authored a declaration file following the steps of this guide, it is time to publish it to npm. There are two main ways you can publish your declaration files to npm:
bundling with your npm package
publishing to the @types organization on npm.
If your types are generated by your source c... | TypeScript: Documentation - Publishing |
https://www.typescriptlang.org/docs/handbook/intro-to-js-ts.html | JS Projects Utilizing TypeScript
The type system in TypeScript has different levels of strictness when working with a codebase:
A type-system based only on inference with JavaScript code
Incremental typing in JavaScript via JSDoc
Using // @ts-check in a JavaScript file
TypeScript code
TypeScript with strict enabled
... | TypeScript: Documentation - JS Projects Utilizing TypeScript |
https://www.typescriptlang.org/docs/handbook/declaration-files/deep-dive.html | Deep Dive
Declaration File Theory: A Deep Dive
Structuring modules to give the exact API shape you want can be tricky. For example, we might want a module that can be invoked with or without new to produce different types, has a variety of named types exposed in a hierarchy, and has some properties on the module objec... | TypeScript: Documentation - Deep Dive |
https://www.typescriptlang.org/docs/handbook/declaration-files/templates/module-class-d-ts.html | Module: Class
For example, when you want to work with JavaScript code which looks like:
const Greeter = require("super-greeter");
const greeter = new Greeter();
greeter.greet();
To handle both importing via UMD and modules:
// Type definitions for [~THE LIBRARY NAME~] [~OPTIONAL VERSION NUMBER~]
// Project: [~THE P... | TypeScript: Documentation - Module: Class |
https://www.typescriptlang.org/docs/handbook/declaration-files/do-s-and-don-ts.html | Do's and Don'ts
General Types
Number
,
String
,
Boolean
,
Symbol
and
Object
❌ Don’t ever use the types Number, String, Boolean, Symbol, or Object These types refer to non-primitive boxed objects that are almost never used appropriately in JavaScript code.
/* WRONG */
function reverse(s: String): String;
✅ Do us... | TypeScript: Documentation - Do's and Don'ts |
https://www.typescriptlang.org/docs/handbook/declaration-files/templates/global-modifying-module-d-ts.html | Global: Modifying Module
Global-modifying Modules
A global-modifying module alters existing values in the global scope when they are imported. For example, there might exist a library which adds new members to String.prototype when imported. This pattern is somewhat dangerous due to the possibility of runtime conflict... | TypeScript: Documentation - Global: Modifying Module |
https://www.typescriptlang.org/docs/handbook/declaration-files/templates/module-plugin-d-ts.html | Module: Plugin
For example, when you want to work with JavaScript code which extends another library.
import { greeter } from "super-greeter";
// Normal Greeter API
greeter(2);
greeter("Hello world");
// Now we extend the object with a new function at runtime
import "hyper-super-greeter";
greeter.hyperGreet();
The d... | TypeScript: Documentation - Module: Plugin |
https://www.typescriptlang.org/docs/handbook/declaration-files/templates/global-d-ts.html | Global .d.ts
Global Libraries
A global library is one that can be accessed from the global scope (i.e. without using any form of import). Many libraries simply expose one or more global variables for use. For example, if you were using jQuery, the $ variable can be used by simply referring to it:
$(() => {
console.... | TypeScript: Documentation - Global .d.ts |
https://www.typescriptlang.org/docs/handbook/declaration-files/templates/module-function-d-ts.html | Module: Function
For example, when you want to work with JavaScript code which looks like:
import greeter from "super-greeter";
greeter(2);
greeter("Hello world");
To handle both importing via UMD and modules:
// Type definitions for [~THE LIBRARY NAME~] [~OPTIONAL VERSION NUMBER~]
// Project: [~THE PROJECT NAME~]
... | TypeScript: Documentation - Module: Function |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.