Getting Started

Installation

Add the package to a Vue or Nuxt app. There is nothing to register.

Install

npm install @chronicstone/vue-route-query

Requirements

Peer dependencyVersion
vue^3.3.0
vue-router^4.0.0 || ^5.0.0

There is no plugin to install. The composables call useRouter() and create one client per router the first time they run, so they work in any component rendered under your router.

import { 
numberCodec
,
useQueryState
} from '@chronicstone/vue-route-query'
// Inside <script setup> of any routed component: const
page
=
useQueryState
('page',
numberCodec
({
default
: 1 }))
To change the defaults for the whole app, such as making every write add a history entry, register the client yourself before your components run. See History.

Nuxt

Nuxt uses vue-router, so the package works as it is. To skip the imports, add it to the auto-imports in nuxt.config.ts:

nuxt.config.ts
export default defineNuxtConfig({
  imports: {
    presets: [
      {
        from: '@chronicstone/vue-route-query',
        imports: [
          'useQueryState',
          'useQueryStates',
          'dynamicQueryState',
          'stringCodec',
          'numberCodec',
          'booleanCodec',
          'enumCodec',
          'dateCodec',
          'arrayCodec',
          'schemaCodec',
        ],
      },
    ],
  },
})

The first render on the server reads the request URL, so the HTML already matches the query string. See Nuxt and SSR.

Copyright © 2026 Cyprien Thao. Released under the MIT License.