< blog ·

When I extract a composable

I pull Vue logic into a composable for reuse, tests or unclear state — not because the script got long.

I don't extract a composable just because the script passed forty lines. Length isn't complexity. I extract when the same behaviour shows up twice, when I want an isolated test, or when it's unclear who owns state in the template.

A good composable feels like a small API: params in, reactive state out, side effects obvious. A bad one becomes a junk drawer. If I can't name it in three words, it's probably two composables.

On Nuxt I also watch auto-imports. Nice until nobody knows where `useSomething` lives. Clear names and a thin `composables/` folder beat clever abstraction.