Menu

1 / 2

I built a Vite plugin to bring Nuxt-style middleware to Vue

DEV Community·Roya·6 months ago
#vyB7Iexz
#problem#vue#typescript#middleware#plugin
Reading 0:00
15s threshold

Vue is great. Vite is great. Vue Router is great. But there's one area where the "bring your own solution" philosophy starts to show its cracks: navigation guards .

The moment your app needs more than a simple auth check — analytics, permission levels, feature flags, prefetching — you start piling logic into beforeEach and hoping for the best.

What about the existing solutions?

To be fair, there are some community approaches out there:

Roll your own middleware runner — works, but you're reinventing the wheel every project, with no type safety

vue-router-middleware-plugin — closest thing I found, but no TypeScript support for middleware names, no async context handling

Just use Nuxt — valid option, but sometimes you really don't need the full SSR framework for a simple SPA

None of these fully scratched the itch, so I built vite-plugin-vue-middleware .

The goal was simple: make Vue SPA middleware feel as natural as Nuxt, without leaving the Vite ecosystem.

What started as a straightforward…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.