Integrations

Nuxt

Learn how to use Ginjou with Nuxt 3 and 4.

The @ginjou/nuxt module provides first-class support for Nuxt, offering SSR-ready composables, automatic provider configuration, and seamless integration with the Nuxt ecosystem.

Installation

Add the module to your project.

Ginjou relies on @tanstack/vue-query for data fetching and state management.
pnpm add @ginjou/nuxt @tanstack/vue-query

Setup

To set up Ginjou in your Nuxt application, register the module in your configuration and initialize the required providers in your root component.

Configuration

Add @ginjou/nuxt to the modules array in nuxt.config.ts:

nuxt.config.ts
export default defineNuxtConfig({
    modules: [
        '@ginjou/nuxt'
    ],
})

Providers

Use the define*Context functions within the setup block of your root component (usually app.vue) to configure your application.

FunctionDescription
defineFetchersContextRegisters data fetchers for your resources.
defineQueryClientContextRegisters the TanStack Query client.
defineResourceContextDefines resources and their behavior.
defineAuthContextRegisters the authentication provider.
defineAuthzContextRegisters the authorization provider.
defineI18nContextRegisters the internationalization provider.
defineNotificationContextRegisters the notification provider.
You do not need to use defineRouterContext. The Nuxt module automatically configures the router integration.

Configuration Example

Here is an example app/app.vue configured with common providers.

app/app.vue
<script setup lang="ts">
import { defineFetchersContext, defineQueryClientContext } from '@ginjou/vue'
import { QueryClient } from '@tanstack/vue-query'

// 1. Provide the QueryClient
defineQueryClientContext(
    new QueryClient()
)

// 2. Define Data Fetchers
defineFetchersContext({
    default: {
        getList: async ({ resource }) => ({ data: [], total: 0 }),
        getOne: async ({ resource, id }) => ({ data: {} }),
    },
})
</script>

<template>
    <NuxtLayout>
        <NuxtPage />
    </NuxtLayout>
</template>

Async Composables

To fully support Server-Side Rendering (SSR), the module provides "Async" versions of standard Ginjou composables.

These composables leverage Nuxt's useAsyncData to ensure data fetched on the server is correctly hydrated on the client.

Available Composables

ComposableDescription
useAsyncGetOneFetches a single record.
useAsyncGetManyFetches multiple records by ID.
useAsyncGetListFetches a list of records with pagination/filtering.
useAsyncGetInfiniteListFetches an infinite list of records.
useAsyncShowManages state and data for detail views.
useAsyncEditManages state and data for edit forms.
useAsyncListManages state and data for list views.
useAsyncInfiniteListManages state and data for infinite list views.
useAsyncSelectManages state and data for select inputs.
useAsyncAuthenticatedChecks the current authentication status.
useAsyncGetIdentityRetrieves the current user's identity.
useAsyncPermissionsRetrieves the current user's permissions.
useAsyncCanAccessChecks if the current user can access a resource.

Usage Example

Async composables are auto-imported by Nuxt.

<script setup lang="ts">
const { data, isLoading } = await useAsyncGetList({
    resource: 'posts'
})
</script>

<template>
    <div v-if="isLoading">
        Loading...
    </div>
    <ul v-else>
        <li v-for="post in data" :key="post.id">
            {{ post.title }}
        </li>
    </ul>
</template>
Copyright © 2026