@trevor-okwirri/nuxt-query
| Install | |
|---|---|
npm install @trevor-okwirri/nuxt-query |
|
| Latest Version: | 1.0.5 |
| Vue: | 3 |
| License: | MIT |
| Last Updated: | Sep 18, 2026 |
| Links: | GitHub · npm |
@trevor-okwirri/nuxt-query
TanStack Query for Nuxt with SSR hydration, a Nuxt-managed query client, and auto-imported query composables.
Installation
pnpm add @trevor-okwirri/nuxt-query
Add the module to nuxt.config.ts:
export default defineNuxtConfig({
modules: ['@trevor-okwirri/nuxt-query'],
})
The module creates one query client per Nuxt app, transfers prefetched query state from the server to the browser, and auto-imports the query composables.
Usage
<script setup lang="ts">
const { data, status } = useQuery({
queryKey: ['todos'],
queryFn: () => $fetch('/api/todos'),
})
</script>
<template>
<p v-if="status === 'pending'">Loading...</p>
<pre v-else>{{ data }}</pre>
</template>
The following APIs are auto-imported:
useQueryuseInfiniteQueryuseQueriesuseMutationuseQueryClientusePrefetchQueryusePrefetchInfiniteQueryuseIsFetchinguseIsMutatinguseMutationStatequeryOptionsinfiniteQueryOptionsmutationOptionskeepPreviousData
The module also exports the query client, cache classes, composables, and TanStack Query core types for explicit imports when needed.
SSR
Queries used during server rendering are dehydrated into Nuxt state and hydrated into the browser's query client. Query functions should therefore be safe to execute on the server and should use absolute URLs or server-compatible fetching when required by the application.
Local development
pnpm install
pnpm dev
pnpm test
pnpm check-types
pnpm prepack
The playground directory is a small Nuxt application used to exercise the
module locally. It is part of this repository only and is not included in the
published package.
License
MIT
Related Packages
Mark Nuxt app hydration with a DOM attribute for CSS, scripts, and end-to-end te...
Production-ready error boundaries for Vue 3 — declarative component, useErrorBou...
Nuxt integration for Verbaly: zero-config module with per-request locale negotia...
Version History
| Version | Released | Vue | License |
|---|---|---|---|
| 1.0.5 | ^3.0 | MIT | |
| 1.0.4 | ^3.0 | MIT | |
| 1.0.1 | ^3.0 | MIT | |
| 1.0.0 | ^3.0 | MIT |