Write better Vue and Nuxt code.

A highly curated collection of practical tips, advanced patterns, and performance tweaks for Vue & Nuxt.

useTip.ts
const { tip } = useAsyncData(
Β Β 'awesome-trick',
Β Β () => queryContent().findOne()
)

Popular Topics
vue
nuxt
vite

In Vue.js, an active component instance will be unmounted when switching away from it by default. But what if you want to preserve the state when switching components? You can wrap it with the built-in <KeepAlive> component to preserve and cache the state. πŸ’ͺ🏻

<template>
<KeepAlive>
  <component :is="activeComponent" />
</KeepAlive>
</template>