DEV Community

Serhii Muzalov
Serhii Muzalov

Posted on

How many times did you write the same watch + execute + loading in different components? 😅 Three tiny things that ruin data‑fetching UX

If you’ve ever written the same watch + execute + loading dance in multiple Vue components, you’re not alone.

I’ve been doing that too — until I built vue‑muza‑use, my API‑layer library for Vue 3.

In versions 0.9.0 and 0.10.0, I killed several small, but very annoying data‑fetching patterns that kept repeating across codebases.

Here’s how I did it, and why you probably don’t want them in your components anymore.

💡 vue‑muza‑use 0.9.0 — what changed

Over the last month, vue‑muza‑use has already reduced the amount of API‑related code by 2–3x in four production projects.

Notable additions:

  • watch + reactive data / params — subscribe directly inside useApi, instead of adding a separate watch every time. You declare what to watch, and the library handles the rest.
  • ignoreUpdates — turns off automatic re‑firing when you update filters, inspired by watchIgnorable from VueUse, but built into the composable. Makes request behavior explicit and predictable.
  • lightweight cache — just cache: 'categories' on GET and invalidateCache: 'categories' on POST/PUT/DELETE. No subscriptions, no complex logic, just in‑memory caching and explicit invalidation.

Right now, there are about 170 tests, and I’m focusing on making the API match what you already know from Vue — watch, immediate, refs — so you don’t have to learn anything entirely new.

Why should you try vue‑muza‑use?

  • It builds on what you already know: watch, immediate, reactive refs. No paradigm shift, no extra concepts.
  • The library is small and takes about 5–10 minutes to configure.
  • Built‑in refreshToken support with a ready‑to‑go queue logic — just plug it into a plugin with 5–10 lines of code.
  • And starting with 0.10.0, there’s a Claude Code skill that knows your useApi<TRaw, TSelected> pattern and all options (SWR, poll, watch, select, cache, ignoreUpdates), so you don’t need to “teach” AI every time.

If you want to talk, walk through a use‑case, or just have a quick dev‑call — I’m open to chat 🙂

🔗 npm: https://www.npmjs.com/package/@ametie/vue-muza-use

🔗 GitHub: https://github.com/MortyQ/vue-useApi

Top comments (0)