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: Automatically Import Components Image

Vue Tip: Automatically Import Components

Use the unplugin-vue-components tool to automatically import your Vue components.
Pinia Tip: Simple History With Undo and Redo Functionality Image

Pinia Tip: Simple History With Undo and Redo Functionality

Build a simple history with undo and redo functionality using the useRefHistory composable from VueUse.
Vue Tip: Accessing Template Ref in Child Component Image

Vue Tip: Accessing Template Ref in Child Component

Learn how to access template refs in a child component within a Vue.js application, enabling you to manipulate and interact with specific elements in the child component's template from the parent component.
Nuxt Tip: How to Fix "Nuxt Instance Unavailable" Error Image

Nuxt Tip: How to Fix "Nuxt Instance Unavailable" Error

If you are using Nuxt 3, you probably already encountered the 'Nuxt Instance Unavailable' error. What is it, and how to fix it?
Vue Tip: Dynamic Slot Names Image

Vue Tip: Dynamic Slot Names

Dynamic directive arguments also work on v-slot, allowing the definition of dynamic slot names.
Nuxt Tip: Detecting Server vs. Client-Side Code Execution Image

Nuxt Tip: Detecting Server vs. Client-Side Code Execution

Nuxt 3 provides a way to detect whether your code is running on the server or client-side.
Vue Tip: Event Handling Image

Vue Tip: Event Handling

There are different ways how to handle events in Vue. Let's take a look at them.
Vue Tip: Use Your Composables Synchronously Image

Vue Tip: Use Your Composables Synchronously

You should always call your composables synchronously in setup() hook or <script setup>. Otherwise Vue will not be able to determine the current active component instance and cannot correctly register features like lifecycle hooks, watchers, and computed properties.
Nuxt Tip: Custom SPA Loading Template for Your Nuxt Application Image

Nuxt Tip: Custom SPA Loading Template for Your Nuxt Application

When using the client-side rendering mode, Nuxt will display a loading indicator until the application is hydrated. The loading indicator is a simple spinner. You can customize the loading indicator by creating a custom loading component.
Vue Tip: Deep Watch on Arrays Image

Vue Tip: Deep Watch on Arrays

In Vue 3, when using the watch option to watch an array, the callback will only trigger when the array is replaced. To trigger the watcher on mutation, the deep option must be specified.