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: Trigger Transition Programmatically Image

Vue Tip: Trigger Transition Programmatically

You can programmatically trigger a transition via the "key" attribute.
Vue Tip: Passing Slots to Child Components Image

Vue Tip: Passing Slots to Child Components

In certain scenarios, you need to pass on all slots from a parent component to the child component.
Nuxt Tip: Cancel Fetch API Request Image

Nuxt Tip: Cancel Fetch API Request

In Nuxt 3, you can use the `signal` parameter with the globally available `$fetch` helper to cancel an API request.
Vue Tip: Check if Component Has Event Listener Attached Image

Vue Tip: Check if Component Has Event Listener Attached

Sometimes, you want to apply specific styles to a component only if it has an event listener attached.
Vue Tip: Watch Slot Changes Image

Vue Tip: Watch Slot Changes

You can use the MutationObserver API to react to changes in the slot content.
Nuxt Tip: Handle Client-Side Errors Image

Nuxt Tip: Handle Client-Side Errors

Nuxt provides the NuxtErrorBoundary component to handle client-side errors.
Vue Tip: Best Way to Force Re-Render Vue Component Image

Vue Tip: Best Way to Force Re-Render Vue Component

In certain scenarios, Vue's reactivity approach isn’t sufficient, and we need to force re-rendering of specific components.
Vue Tip: Document Your Component Props Using JSDoc Image

Vue Tip: Document Your Component Props Using JSDoc

You can use JSDoc to document your component props so that they show up when you hover over the component in your IDE.
Vue Tip: Composable to Define Keyboard Shortcuts Image

Vue Tip: Composable to Define Keyboard Shortcuts

I show you a handy Vue composable that allows you to define keyboard shortcuts in your app.
Vue Tip: Use a Head Manager Image

Vue Tip: Use a Head Manager

Unhead is a framework-agnostic document head manager that can be used to manage page metadata like the title in your Vue application.