A Nuxt module for Directus with built-in authentication, realtime, file management, type generation, and visual editor support.
@nuxt/image integration@directus/visual-editing@directus/visual-editing v2 and @directus/sdk v21)nuxt-directus-sdk dependency to your project# Using pnpm
pnpm add -D nuxt-directus-sdk
# Using yarn
yarn add --dev nuxt-directus-sdk
# Using npm
npm install --save-dev nuxt-directus-sdk
# Using bun
bun install --save-dev nuxt-directus-sdk
nuxt-directus-sdk to the modules section of nuxt.config.tsexport default defineNuxtConfig({
modules: ['nuxt-directus-sdk'],
directus: {
url: process.env.DIRECTUS_URL,
},
})
.env file:DIRECTUS_URL=https://your-directus-url.com
DIRECTUS_ADMIN_TOKEN=your_admin_token # Optional: required for type generation
That's it! You can now use Directus within your Nuxt app ✨
For cross-domain setups (e.g. app.example.com and api.example.com), see the Authentication Guide.
The module ships with a CLI for type generation and permissions/rules sync that doesn't require a running Nuxt instance. Useful in CI, pre-commit hooks, or quick regeneration during development.
# Generate TypeScript types from a Directus schema
npx nuxt-directus-sdk generate-types --prefix App -o types/directus.d.ts
# Pull permissions/rules to a JSON file
npx nuxt-directus-sdk rules:pull -o rules.json
# See all commands
npx nuxt-directus-sdk --help
See the CLI documentation for flags and examples.
!IMPORTANT The playground uses the directus-template-cli
cmstemplate. Apply the template withnpx directus-template-cli@latest applyand follow the interactive prompts.
# Install dependencies
pnpm install
# Add DIRECTUS_ADMIN_TOKEN to playground .env (don't forget to update your token)
cp ./playground/.env.example ./playground/.env
# Generate type stubs
pnpm run dev:prepare
# Develop with the playground
pnpm run dev
# Build the playground
pnpm run dev:build
# Run ESLint
pnpm run lint
# Run Vitest
pnpm run test
pnpm run test:watch
# Release new version (see RELEASING.md)
pnpm run release
Contributions are welcome. Please target the next branch for new features and fixes; main is reserved for stable releases and hotfixes. See RELEASING.md for the release process.