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.

Nuxt Tip: Analyse Production Bundle Image

Nuxt Tip: Analyse Production Bundle

Nuxi analyze is an experimental feature that builds your Nuxt app and analyses the production bundle.
Pinia Tip: Use Setup Stores for More Flexibility Image

Pinia Tip: Use Setup Stores for More Flexibility

Besides Option Stores you can also use Setup Stores to define stores in Pinia. They bring more flexibility as you can create watchers within a store and freely use any composable.
Nuxt Tip: Adding a Latest Route Image

Nuxt Tip: Adding a Latest Route

Utilizing Nuxt Middleware, you can implement an easy way for visitors to always read the latest blog posts (or any other content) without needing to know its name or specific URL.
Vue Tip: Typing Component Events Image

Vue Tip: Typing Component Events

To declare emits with full type inference support, we can use the defineEmits API, which is automatically available inside <script setup>.
Vue Tip: Dynamically Change Page Title Image

Vue Tip: Dynamically Change Page Title

I will show you a few ways how you can easily change the page title when navigating your application
Vue Tip: Access DOM in Watcher Callback After Vue Updated It Image

Vue Tip: Access DOM in Watcher Callback After Vue Updated It

To access the DOM after Vue has updated it in a watcher callback, you can use the flush post option.'
Vue Tip: Pass Custom Arguments to Event Handler Method Image

Vue Tip: Pass Custom Arguments to Event Handler Method

Sometimes we need to pass custom arguments to the event handler method and access the original DOM event.
Vue Tip: Avoid Mutating a Prop Directly Image

Vue Tip: Avoid Mutating a Prop Directly

Mutating props is an anti-pattern. You should use computed properties instead.
Vue Tip: Disable Attribute Inheritance Image

Vue Tip: Disable Attribute Inheritance

By default, parent scope attribute bindings that are not recognized as props will "fallthrough". This may not always be the desired behavior and, therefore, can be disabled. A typical use case is a component with multiple root nodes.
Vue Tip: Dynamically Add & Remove Route While App Is Running Image

Vue Tip: Dynamically Add & Remove Route While App Is Running

Adding routes to your router is usually done via the `routes` option, but in some situations, you might want to add or remove routes while the application is already running.