Setup
Installation
Add @nuxtjs/strapi module to your project:
npx nuxi@latest module add strapi
This will add the module to the modules section of your nuxt.config.ts. You can then configure it:
export default defineNuxtConfig({
modules: ['@nuxtjs/strapi'],
strapi: {
// Options
}
})
Options
Defaults:
{
url: process.env.STRAPI_URL || 'http://localhost:1337',
token: process.env.STRAPI_TOKEN || undefined,
prefix: '/api',
admin: '/admin',
version: 'v5',
cookie: {},
cookieName: 'strapi_jwt'
}
If you want to override any options on runtime, you may use Nuxt runtime-config:
export default defineNuxtConfig({
// Example of separate client/server URLs
runtimeConfig: {
strapi: {
url: 'http://localhost:1337'
},
public: {
strapi: {
url: 'http://localhost:1337'
}
}
}
})
url
URL of the Strapi server.
Environment variable STRAPI_URL can be used to override url.
admin
Specify admin prefix used by your Strapi.
prefix
Prefix of the Strapi server. Not for version v3.
Learn how to change the default API prefix in your Strapi server.
version
Version of the Strapi server. Can only be v5/v4/v3.
cookie
Cookie options of the Strapi token cookie.
All cookie options can be found in the Nuxt documentation
cookieName
Cookie name of the Strapi token cookie
auth.populate v1.5.0+ Strapi v4.2.2+
Configure the populate query param of the /users/me route.
Learn more on Populating documentation.
auth.fields v1.7.0+ Strapi v4.2.2+
Configure the fields query param of the /users/me route.
Learn more on Field Selection documentation.
devtools v1.9.0+
Embed the Strapi admin to the Nuxt Devtools, read more in the Devtools section.
Continuous releases
Nuxt Strapi uses pkg.pr.new for continuous preview releases, providing developers with instant access to the latest features and bug fixes without waiting for official releases.
Automatic preview releases are created for all commits and PRs to the main branch. Use them by replacing your package version with the specific commit hash or PR number.
{
"dependencies": {
- "@nuxtjs/strapi": "^2.1.1",
+ "@nuxtjs/strapi": "https://pkg.pr.new/@nuxtjs/strapi@95260d0",
}
}