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.

#132 · Latest

Nuxt Tip: Difference Between useFetch and event.$fetch

Understand the key distinction between useFetch and event.$fetch in Nuxt. Learn why using event.$fetch for server-side API calls is the recommended approach for better performance and SSR correctness.

2 minNuxt
#127

Nuxt Tip: Parallel Fetch Requests

Learn to wield useAsyncData along with Promise.all() to load data faster with parallel requests in your Nuxt application.

1 minNuxt
#121

Nuxt Tip: Run Code Once During SSR or CSR

Since Nuxt 3.9 you can use the useOnce composable to run a given function or block of code once during server-side rendering or client-side navigation.

1 minNuxt
#120

Vue Tip: How I Write Class & Style Bindings

Styling your components in Vue.js can be done in multiple ways. One of the most common ways is to use the class attribute, especially if you are using a CSS framework like Tailwind. In combination with v-bind you can dynamically assign classes to your components.

1 minTemplate
#119

Vue Tip: When You Should Use a Composable

Vue composables are a way to encapsulate logic in a reusable way in Vue 3. They are a great way to share logic between components, but I often see them used in places where they are not needed.

1 minScript
#116

Nuxt Tip: Use Environment-Specific Configurations

It sometimes happens that you need to have different configurations for different environments in your Nuxt.js application. Therefore, Nuxt provides fully typed, per-environment overrides for your Nuxt configuration.

1 minNuxt
#110

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.

1 minNuxt
Page 1 of 6