Runable v1.0.0-alpha.20
Why Runable? Docs Modules Work with AI Blog About Changelog
  • 01Why Runable?
  • 02Docs
  • 03Modules
  • 04Work with AI
  • 05Blog
  • 06About
  • 07Changelog
Vue without a fixed server runtime.
Getting Started Structure Integrations Guide MCP API
  • Getting Started Structure Integrations Guide MCP API
Build the Interface
  • Routing
  • Layouts
  • Middlewares
  • Error Handling
Load and Render
  • Data Fetching
  • SSR and CSR
  • Head and SEO
Extend Runable
  • Auto-imports
  • Plugins
  • Modules
Configure and Ship
  • Runtime Configuration
  • CSS and Assets
  • Production Build
CLI
  • Overview
  • Create
  • Prepare
  • Build
  • MCP
  • AI Skills
  • Inspector

Middleware

Allow, block, or redirect navigation before displaying a page.

Files in app/middlewares/ are Vue Router guards. They run in the browser and during SSR navigation.

Create named middleware

// app/middlewares/auth.ts
export default defineVueMiddleware((to) => {
  const authenticated = false;

  if (!authenticated) {
    return { path: "/login", query: { redirect: to.fullPath } };
  }
});

Attach it to a page using its file name:

<script setup lang="ts">
definePageMeta({ middleware: ["auth"] });
</script>

Create global middleware

Add the .global suffix to run it on every navigation:

// app/middlewares/analytics.global.ts
export default defineVueMiddleware((to, from) => {
  console.debug("navigation", from.fullPath, to.fullPath);
});

Control navigation

Middleware can return:

Return valueResult
undefined or trueContinue navigation
falseCancel navigation
A routeRedirect to that route
A thrown errorTrigger router error handling

You can declare several middleware functions:

definePageMeta({ middleware: ["auth", "admin"] });

Runable loads required middleware, removes duplicates, and runs them in order. Global middleware runs before route middleware.

Vue middleware, not HTTP middleware

This mechanism controls interface navigation. Keep real authentication and API-route protection in Express, Fastify, Hono, or your backend.

Report an issue Edit this page
Layouts

Share an interface structure across pages without duplicating templates.

Error Handling

Capture Vue, Router, and browser errors in a consistent interface.

On this page

  • 1Create named middleware
  • 2Create global middleware
  • 3Control navigation
Runable

The Vue framework that brings productive conventions to any backend.

Product

  • Why Runable
  • Documentation
  • Installation
  • Integrations

Project

  • About
  • Blog
  • Changelog
  • Sponsor

Community

  • GitHub
  • Issues
  • Discussions
  • Bluesky

© 2026 Runable. Released under the MIT License.

Open source Built with Vue and Runable