Quick start
Access text, images, and other media with Nuxt and the Sanity headless CMS.
Setup
-
Install Sanity integration
yarn add @nuxtjs/sanity@0.10.0
npm install @nuxtjs/sanity@0.10.0 --save
-
Enable the module in your Nuxt configuration
nuxt.config.js
{ buildModules: ['@nuxtjs/sanity/module'] }
nuxt.config.js{ modules: ['@nuxtjs/sanity/module'] }
-
Add Sanity configuration
@nuxtjs/sanity
will look for asanity.json
file in your project root directory. Just copy over thesanity.json
from your CMS - and you're fully configured!
Alternatively, you can pass in an object in your Nuxt config with key details.nuxt.config.js{ sanity: { projectId: 'myProject' } }
You can find more about configuring@nuxtjs/sanity
here. -
You're good to go!
Check out how to use Sanity.
TypeScript
@nuxtjs/sanity
offers type definitions. Just add an entry in tsconfig.json
.
tsconfig.json
{
"compilerOptions": {
"types": ["@nuxt/types", "@nuxtjs/sanity"]
}
}
tsconfig.json
{
"compilerOptions": {
"types": ["@nuxt/vue-app", "@nuxtjs/sanity"]
}
}