@easy-cms/nuxt
v0.32.0
Published
Nuxt module for Easy CMS
Maintainers
Readme
@easy-cms/nuxt
Nuxt 4 module for Easy CMS: the REST API, the admin UI and a typed useEasyCMS() inside your Nuxt app. Part of Easy CMS, the embedded, code-first headless CMS for Nuxt and Next.js.
Install
npm install @easy-cms/nuxt @easy-cms/core @easy-cms/db-sqliteOr pnpm add, yarn add or bun add.
Usage
// nuxt.config.ts
export default defineNuxtConfig({
modules: ['@easy-cms/nuxt'],
easyCms: {
// configPath: 'easy-cms.config.ts',
// trustProxy: false, // use X-Forwarded-For for login rate limiting
},
})With easy-cms.config.ts in the project root you get:
REST API at
/api/cms(collections, globals, uploads, login/logout/me); change it withroutes.apiin the Easy CMS config.Admin UI at
/admin(admin.pathin the config).Local API in server routes, typed from your config:
// server/api/posts.get.ts export default defineEventHandler(async (event) => { const cms = await useEasyCMS() const user = await useEasyCMSUser(event) // logged-in Easy CMS user or null return cms.find('posts', { where: { status: { equals: 'published' } } }) })
Development and production
nuxi devpushes schema changes to the database automatically.- In production the schema must match the latest migration. Create migrations with
npx easy-cms migrate:create <name>, deploy theeasy-cms/migrationsfolder, runnpx easy-cms migrate, then start the server from the project root (relative database paths and the migrations folder resolve from the working directory). - The module tells Nitro to ship files the database adapter loads dynamically (libsql's native
binary), so
.outputruns on its own. Build on the same OS/architecture you deploy to.
Links
Nuxt · Documentation (ภาษาไทย) · GitHub
MIT License
