Skip to content

Frontend Routing

Frontend routing is a popular way to switch views in a single-page application. This guide covers recommended approaches for different frontend frameworks when using Wails.

The recommended approach for routing in Vue is Hash Mode:

import { createRouter, createWebHashHistory } from "vue-router";
const router = createRouter({
history: createWebHashHistory(),
routes: [
//...
],
});

Hash mode uses the URL hash to render different views, avoiding issues with the Wails runtime interfering with routing by using the hash-based URL format.

Wails embeds your frontend into a native webview window. Using hash-based routing (#/page instead of /page) avoids conflicts with:

  • The Wails runtime’s internal routing
  • Native window URL handling on different platforms
  • Production assets served from non-root paths

If you’re having issues with frontend routing in production builds:

  • Make sure your frontend build tool is configured to output for hash mode routing
  • For Vite-based projects, add base: "./" to your vite.config.js
  • Verify your index.html handles the fallback properly for SPA routing