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: An URL Object Working on Both Server-Side and Client-Side Image

Nuxt Tip: An URL Object Working on Both Server-Side and Client-Side

Nuxt provides a helper function called useRequestURL that returns an URL object working on both server side and client side.
Vue Tip: Simple State Management With Composition API Image

Vue Tip: Simple State Management With Composition API

Learn how you can use Composition API for a simple state management solution which you can use instead of Pinia.
Vue Tip: Manually Stop Watcher Image

Vue Tip: Manually Stop Watcher

You need to manually stop your Vue watcher if they are created asynchronously. Sync watchers are automatically stopped when the component is unmounted.
Vue Tip: Dynamic Return Values in Composables Image

Vue Tip: Dynamic Return Values in Composables

FIXME
Vue Tip: Use VueUse to Unleash the Power of Utility Functions Image

Vue Tip: Use VueUse to Unleash the Power of Utility Functions

VueUse is a collection of hundreds of essential Vue Composition Utilities for interacting with various browsers, sensors, animations, and state APIs, and more.
Vue Tip: Emit Event From Composable Image

Vue Tip: Emit Event From Composable

Your application may contain a lot of components that are using the same logic, like emitting the same event. In this case, it might be tempting to create a composable that will emit this event and is used in all components. But how do you emit an event from inside a composable?
Vue Tip: Split Your SFC into Multiple Files Image

Vue Tip: Split Your SFC into Multiple Files

Use the 'src' attribute to import an external file for a language block in your Vue Single-File Components (SFC).
Nuxt Tip: Differentiate Client and Server Components Image

Nuxt Tip: Differentiate Client and Server Components

Nuxt allows you to define client-side and standalone server components
Vue Tip: Use Eager Computed Without Lazy Evaluation Image

Vue Tip: Use Eager Computed Without Lazy Evaluation

Computed properties are evaluated lazily which means they are only evaluated when they are accessed. The computedEager() from VueUse is a good alternative for simple operations.
Nuxt Tip: Lazy Load Components in Nuxt 3 Image

Nuxt Tip: Lazy Load Components in Nuxt 3

Learn how you can dynamically import components in Nuxt 3 only when they’re needed.