Provide a type safe router to Nuxt with auto-generated typed definitions for route names and autocompletion for route params
NuxtLink
route autocomplete and params type-checkuseRouter
,useRoute
andnavigateTo
route autocomplete and params type-check- Supports optional params and catchAll routes
- Out of the box
i18n
support - Supports routes extended by config and modules
A beta version with
path
autocomplete is available in versionv3.0.0-beta.0
https://github.com/victorgarciaesgi/nuxt-typed-router/releases/tag/v3.0.0-beta.0
Demo repo 🧪 : nuxt-typed-router-demo
- Nuxt 3
- Nuxt 2 (via
nuxt2
branch)
yarn add -D nuxt-typed-router
# or
npm install -D nuxt-typed-router
# or
pnpm install -D nuxt-typed-router
Nuxt 2 version is no longer maintained, but still available in nuxt2
branch
It only has route name autocomplete functionnality
yarn add -D nuxt-typed-router@legacy
# or
npm install -D nuxt-typed-router@legacy
Register the module in the nuxt.config.ts
, done!
export default defineNuxtConfig({
modules: ['nuxt-typed-router'],
});
- Add
path
autocomplete with TS string templates - Enforce strong params typing depending of origin route
- Add support for
validate
indefinePageMeta
- Add
strict
option to prevent path navigation
- Clone this repository
- Install dependencies using
pnpm
- Build project for local tests
pnpm run test
- Start dev playground
pnpm run prepack && pnpm run dev
- Build project for deploy
pnpm prepack