WXT Pages

File-system based routing for WXT browser extensions

Overview

WXT Pages brings file-based routing to WXT:

/pages
  /+layout.vue      → Wrapper component for all pages
  /index.vue        → /
  /(marketing)
    /about.vue      → /about 
    /contact.vue    → /contact
  /users
    /[id].vue       → /items/:id
    /[id]
      /edit.vue     → /items/:id/edit

It takes the best functionality from Next.js, Nuxt and SvelteKit routers, to make pages and routing as idiomatic and automated as entry point generation.

Fall back on concepts such as layouts, nested routes, route groups, dynamic routes, and more.

Usage

Define routes simply by creating files in a pages directory, and the module automatically generates the configuration:

TypeFileDescription
Standard Pagespages/index.vueRegular files become routes
Nested Routespages/<users>/profile.vueFolders create path segments
Dynamic Parameterspages/posts/[slug].vueSquare brackets create dynamic route segments
Catch-all Routespages/docs/[...slug].vueTriple dots create catch-all routes to any depth
Flat Route Formatpages/users_[id]_edit.vueUnderscores also generte nested folders
Route Groupspages/(marketing)/about.vueParentheses nest folders but not the URL
Layoutspages/dashboard/+layout.vueLayout files wrap all routes in the same directory
Index Routespages/dashboard/+index.vueIndex route files create nested route structures
Ignored Filespages/_components/Button.vueFolders or files starting with _ or . are ignored
Scoped Pages<layer>/pages/@global/shared.vueGenerate routes in the specified scope

WXT Pages is effectively a powerful page based router, with drivers for Vue, React, Preact, Svelte, Solid, and Angular make manual route configuration needless.

Benefits

Whilst small projects won't benefit from file-based routing, pages simplifies large extension development:

  • Zero configuration routing that just works
  • Type-safe routes with TypeScript support
  • Hot module replacement during development
  • Familiar patterns from modern web frameworks
  • Clean architecture with conventional file structure

So...

I hope you found this post interesting or useful.

If you want to engage further, follow me on Twitter, Bluesky, or drop a comment or reaction below.

Either way, thanks for reading!