Skip to content

Nuxt

The PikaCSS Nuxt module provides zero-config integration for Nuxt applications.

sh
pnpm add -D @pikacss/nuxt-pikacss
sh
npm install -D @pikacss/nuxt-pikacss
sh
yarn add -D @pikacss/nuxt-pikacss

Add the module to nuxt.config.ts:

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

WARNING

When you use @pikacss/nuxt-pikacss, do not also register @pikacss/unplugin-pikacss/vite manually in vite.config.ts. The Nuxt module already wires the Vite plugin and generates a Nuxt plugin template that imports pika.css.

What the Module Does

Vite Plugin Registration

The module automatically registers @pikacss/unplugin-pikacss/vite with enforce: 'pre', ensuring style extraction runs before other transformations.

CSS Auto-Import

The module generates a Nuxt plugin template that imports pika.css, so you do not need to manually import the generated CSS file yourself.

Default Scan Patterns

By default, the module scans **/*.{js,ts,jsx,tsx,vue} files. Configure the scan option to customize file patterns.

Config

The Nuxt module accepts all Unplugin options with Nuxt-specific defaults applied automatically.

PropertyDescription
cwdExplicit working directory for path resolution. Overrides the bundler-detected project root.
scanFile glob patterns controlling which source files are scanned for pika() call sites.
configPikaCSS engine configuration, either as an inline object or a path to a config module.
autoCreateConfigWhen true, auto-creates a PikaCSS config file if none is found.
fnNameFunction identifier the scanner looks for when extracting call sites. Default: 'pika'.
transformedFormatOutput shape of transformed pika() calls: 'string' or 'array'.
tsCodegenControls TypeScript type-definition code generation.
cssCodegenControls CSS code-generation output.

See API Reference — Nuxt for full type signatures and defaults.

Next

  • Unplugin — use PikaCSS with other bundlers.
  • Setup — basic project setup.