Have a vue-tiful morning!
Pocket Vue The composables and patterns I repeat from project to project, the cheat sheet I always end up looking for, and my Vue bookmarks.
Recipe of the day A different one every day, running right here. Click it, type in it, break it.
Another↻ Search without hammering: a debounced ref With customRef the ref only reports once you stop typing. It works with v-model as is, and search doesn't fire on every key.
What AI usually gets wrong. It wraps the input handler in lodash's debounce, which fights v-model, or puts a setTimeout in a watch without clearing the previous one: every search still fires, just late.
See the code →
v-model on your components with defineModel One line instead of the modelValue prop, the update:modelValue emit and the computed that tied them together.
What AI usually gets wrong. It hand-writes the modelValue prop and emit('update:modelValue'), like before Vue 3.4. Or worse, does props.modelValue++ and the parent never knows.
See the code →
Adultos − 2 +
Niños − 0 +
Sois 2.
Lists that reorder with animation TransitionGroup with the -move class: each item glides to its new spot. Respects “reduce motion”.
What AI usually gets wrong. It uses the index as :key, so the animation moves the wrong items, and it leaves out position: absolute on what leaves: the rest jump instead of sliding.
See the code →
Barajar Añadir · clic en una para quitarla
Destructure props without losing reactivity Since Vue 3.5 destructured props stay reactive and the defaults go right there. Goodbye withDefaults().
What AI usually gets wrong. Either it tells you destructuring props breaks reactivity (true before 3.5) and reaches for withDefaults, or it destructures and passes the prop as is to watch or a composable, where it must go as a getter: () => amount.
See the code →
A computed you can write to With get and set, a v-model can bind to a derived value and spread it across the real refs.
What AI usually gets wrong. It syncs two refs with two watchers, one each way, that chase each other and sometimes loop, when one computed with get and set does it in one place.
See the code →
Each one is a real component running on the page, with its code alongside to copy.
All the recipes →
Did a chat write that component? Paste it and I'll flag what usually goes wrong: lost reactivity, mutated props, listeners never removed… with the fix and a report to hand back.
Check a component →
When it fits and when it doesn't, against React, Svelte, Angular and Solid, and when you need no framework at all.
See the comparison →
Libraries, tools, places to learn and the people who make Vue. They come from the joedoe.dev shelf.
All the links →