Here's how to install and configure Nuxt Crouton in your Nuxt 4 project.
app/ directory structure convention used by layers. See Troubleshooting - Layer Pages 404 if you encounter routing issues.You'll need Node.js 18 or 20+, pnpm (recommended) or npm, Nuxt 4.x, and Nuxt UI 4.x.
# Install main module
pnpm add @fyit/crouton
# Install generator (dev dependency)
pnpm add -D @fyit/crouton-cli
Add Nuxt Crouton to your nuxt.config.ts:
export default defineNuxtConfig({
modules: ['@fyit/crouton'],
// Optional: Enable additional features
crouton: {
// Core features (enabled by default)
auth: true,
admin: true,
i18n: true,
// Optional features (enable as needed)
editor: false, // Rich text editing
assets: false, // Asset management
ai: false, // AI integration
email: false, // Email templates
pages: false, // CMS pages
// ... see Package Architecture for all options
},
// Recommended: Enable hot reload for development
vite: {
server: {
watch: {
ignored: ['!**/node_modules/@fyit/**']
}
},
optimizeDeps: {
exclude: ['@fyit/crouton']
}
}
})
@fyit/crouton-core (CRUD), @fyit/crouton-auth (authentication), @fyit/crouton-admin (super admin), and @fyit/crouton-i18n (translations). No separate installation needed for these core features.Nuxt Crouton layers use Tailwind CSS classes that need to be scanned by the Tailwind compiler. Due to how Tailwind CSS v4 works with Nuxt Layers, you need to add the @source directive to your app's CSS file to ensure layer components are properly styled.
crouton-generate) and installer (crouton-install) will automatically configure the @source directive for you! If you run either of these commands, you can skip manual configuration.When you run the generator or installer, it will:
app/assets/css/main.css)@source directive automaticallynuxt.config.ts if a new CSS file was created# The generator sets up CSS automatically
npx crouton-generate <layer> <collection> --fields-file=./schema.json
If automatic setup fails or you prefer manual configuration, create or update your main CSS file (e.g., app/assets/css/main.css):
@import "tailwindcss";
@import "@nuxt/ui";
/* Scan Nuxt Crouton layers - REQUIRED for proper styling */
@source "../../../node_modules/@fyit/crouton*/app/**/*.{vue,js,ts}";
@source directive path is relative to your CSS file location. Adjust the ../ depth based on where your CSS file is located:app/assets/css/main.css: use "../../../node_modules/..."app.css: use "../node_modules/..."node_modules. The @source directive explicitly tells Tailwind where to find classes used in layer components. Without this, hover states and dynamic classes won't work. Learn moreThe wildcard pattern @fyit/crouton*/ automatically scans all installed Nuxt Crouton layers:
@fyit/crouton@fyit/crouton-i18n@fyit/crouton-editor@fyit/crouton-assetsAlternatively, you can list each layer explicitly:
@source "../../../node_modules/@fyit/crouton/app/**/*.{vue,js,ts}";
@source "../../../node_modules/@fyit/crouton-i18n/app/**/*.{vue,js,ts}";
@source "../../../node_modules/@fyit/crouton-editor/app/**/*.{vue,js,ts}";
Check that the generator is installed correctly:
npx crouton-generate --help
You should see:
Usage: crouton-generate <layer> <collection> [options]
Before running the generator, ensure you've completed these steps:
pnpm add @fyit/crouton
pnpm add -D @fyit/crouton-cli
The generator checks that the module is properly configured:
modules: ['@fyit/crouton']
Create JSON schema files defining your collection fields. See Schema Format.
npx crouton-generate <layer> <collection> --fields-file=./schema.json
@fyit/crouton to the modules array in nuxt.config.ts.Now that Nuxt Crouton is installed, continue to Usage to generate your first collection.