Vue tips · 132 tips

Vue & Nuxt tips

Over the last few years, I've collected a list of valuable tips while developing and writing about Vue & Nuxt. Some are clever, some I use almost every day, and some are more advanced — but they're all useful.

Vue Tip: Force-Enable Vue Devtools in Production Build Image

Vue Tip: Force-Enable Vue Devtools in Production Build

Usually, the Vue Devtool extension is disabled in production builds, but there is a way to force-enable it.
Vue Tip: Use Provide & Inject to Avoid Prop Drilling Image

Vue Tip: Use Provide & Inject to Avoid Prop Drilling

Props are the standard way to pass data from the parent to a child component. Sometimes, we want to share data from a parent component to all its children components without using a store. Provide / Inject solves this problem and avoids prop drilling.
Vue Tip: Change the Interpolation Delimiter Image

Vue Tip: Change the Interpolation Delimiter

It is possible to adjust the delimiters used for text interpolation within the template to avoid conflicting with server-side frameworks that also use mustache syntax.
Vue Tip: Use Vue Without Build Step Image

Vue Tip: Use Vue Without Build Step

When using Vue from a CDN, no "build step" is involved. This makes the setup much more straightforward and is suitable for enhancing static HTML or integrating with a backend framework.
Vue Tip: Defining and Registering Vue Web Components Image

Vue Tip: Defining and Registering Vue Web Components

Web Components is an umbrella term for a set of web native APIs that allows developers to create reusable custom elements. Vue has excellent support for both consuming and creating custom elements.
Vue Tip: Share Composable State Across Components Image

Vue Tip: Share Composable State Across Components

It is possible to sync composable state across components by lifting its definition outside the exported function.
Vue Tip: Expose Properties in a Script Setup Component Image

Vue Tip: Expose Properties in a Script Setup Component

Components using script setup are closed by default and will not expose any of the bindings declared inside script setup.
Vue Tip: Expose Slots From a Child Component  Image

Vue Tip: Expose Slots From a Child Component

Third-party components are often wrapped in a custom component. But in that way, the slots of the third-party component get lost.
Vue Tip: Lifecycle Hooks for Debugging Image

Vue Tip: Lifecycle Hooks for Debugging

Vue provides two lifecycle hooks that we can use for debugging purposes.
Vue Tip: Typing Template Refs With TypeScript Image

Vue Tip: Typing Template Refs With TypeScript

Template refs only exist after the component is mounted. Thus, it’s necessary to type template refs with a union type that includes the DOM element type as well as null.