nuxt-codegen

GraphQL Code Generator module for Nuxt 3
2,347 4
Install
npm install nuxt-codegen
Latest Version:1.3.1
Vue:3
License:MIT
Last Updated:Mar 1, 2026
Links: GitHub  ·  npm
Maintainer: eugenistoc

nuxt-codegen

This module integrates GraphQL Code Generator in your development flow.

Quick setup

  1. Add nuxt-codegen dependency to your project
# Using yarn
yarn add nuxt-codegen -D

# Using npm
npm install nuxt-codegen -D

# Using pnpm 
pnpm add nuxt-codegen -D
  1. Add nuxt-codegen to the modules section of nuxt.config.ts
export default defineNuxtConfig({
    modules: ['nuxt-codegen']
})

Note you also need graphql, and the plugins you want to use.

  1. Create your codegen.ts configuration file in the project's rootDir or use the Initialization Wizard

The code generator will now be executed before each build or after any changes made to your graphql documents.

Configuration

export default defineNuxtConfig({
  modules: ["nuxt-codegen", {
    /**
     * @default true
     * Only run codegen in development mode
     */

    devOnly: boolean;
    /**
     * @default ['.graphql', '.gql']
     * Which file extensions to watch for changes.
     */
    extensions: string[];

    /**
     * @default codegen.ts
     * Path to the config file (e.g. ./configs/codegen.config.ts)
     */
    configFile: string
  }],
});

Prior art

Development

  1. Clone this repository
  2. Install dependencies using pnpm pnpm install
  3. Prepare for development using pnpm dev:prepare
  4. Start development server using pnpm dev

Version History

Version Released Vue License
1.3.1 ^3.0 MIT
1.3.0 ^3.0 MIT
1.2.1 ^3.0 MIT
1.2.0 ^3.0 MIT
1.1.0 ^3.0 MIT