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: Change Status Code of the Response Image

Nuxt Tip: Change Status Code of the Response

`setResponseStatus` is a Nuxt composable to set the status code and (and optionally the status message) of the response.
Nuxt Tip: Run Code Once During SSR or CSR Image

Nuxt Tip: Run Code Once During SSR or CSR

Since Nuxt 3.
Vue Tip: How I Write Class & Style Bindings Image

Vue Tip: How I Write Class & Style Bindings

Styling your components in Vue.
Vue Tip: When You Should Use a Composable Image

Vue Tip: When You Should Use a Composable

Vue composables are a way to encapsulate logic in a reusable way in Vue 3.
Vue Tip: Mutate Your State Inside of the Provider Using Provide and Inject Image

Vue Tip: Mutate Your State Inside of the Provider Using Provide and Inject

When using reactive provide/inject values, it is recommended to keep any mutations to reactive state inside of the provider whenever possible.
Vue Tip: Share Styling Using Wrapper Components Image

Vue Tip: Share Styling Using Wrapper Components

Wrapper components can help you share styling across multiple Vue components.
Nuxt Tip: Use Environment-Specific Configurations Image

Nuxt Tip: Use Environment-Specific Configurations

It sometimes happens that you need to have different configurations for different environments in your Nuxt.
Vue Tip: Validate Props in Script Setup With TypeScript Image

Vue Tip: Validate Props in Script Setup With TypeScript

For prop validations inside `<script setup>` with TypeScript you need to define an interface for the props and use the `withDefaults` helper to set default values.
Nuxt Tip: How Nuxt Uses Nitro, h3 and ofetch Internally Image

Nuxt Tip: How Nuxt Uses Nitro, h3 and ofetch Internally

Nitro, h3 and ofetch are UnJS packages that are used to power the Nuxt 3 server engine.
Vue Tip: Don't Use Reactive Object for Template Refs Image

Vue Tip: Don't Use Reactive Object for Template Refs

Template Refs are a way to access elements in the DOM from within a Vue component.