Integrations

Vue

Learn how to integrate Ginjou into your Vue 3 applications.

The @ginjou/vue package provides the core integration for Vue 3 applications. It uses a headless context pattern to inject configuration and state management into your app.

Installation

Add the package to your project.

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

Setup

Ginjou uses a Context API pattern to provide configuration to your application. Instead of a single monolithic plugin, you use granular define*Context functions within the setup block of your root component (usually App.vue).

Context Providers

Use these functions to register specific capabilities:

FunctionDescription
defineFetchersContextRegisters data fetchers for your resources.
defineQueryClientContextRegisters the TanStack Query client.
defineResourceContextDefines resources and their behavior.
defineRouterContextConnects the router integration.
defineAuthContextRegisters the authentication provider.
defineAuthzContextRegisters the authorization provider.
defineI18nContextRegisters the internationalization provider.
defineNotificationContextRegisters the notification provider.

Configuration Example

Import and call your definition functions within the <script setup> block of your root component.

Registering providers in the root component ensures that context is available to all child components and remains consistent during SSR.
App.vue
<script setup lang="ts">
import { defineFetchersContext, defineQueryClientContext, defineRouterContext } from '@ginjou/vue'
import { createRouter } from '@ginjou/with-vue-router'
import { QueryClient } from '@tanstack/vue-query'
import { RouterView } from 'vue-router'

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

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

// 3. Integrate the Router
defineRouterContext(
    createRouter()
)
</script>

<template>
    <RouterView />
</template>

Integrations

Use these packages to bridge Ginjou with other libraries in the Vue ecosystem.

Vue Router

The @ginjou/with-vue-router package connects Ginjou's navigation logic with vue-router.

import { defineRouterContext } from '@ginjou/vue'
import { createRouter } from '@ginjou/with-vue-router'

// In setup()
defineRouterContext(createRouter())

Vue I18n

The @ginjou/with-vue-i18n package connects Ginjou's localization features with vue-i18n.

import { defineI18nContext } from '@ginjou/vue'
import { createI18n } from '@ginjou/with-vue-i18n'

// In setup()
defineI18nContext(createI18n())
Copyright © 2026