Site config can be set from many different sources from each environment.
For a full list see how it works.
At a minimum, it's recommended you provide a url, env and name for your site.
If you only run your site in development and live environments, you can safely set your site config in your nuxt.config.ts file.
export default defineNuxtConfig({
site: {
url: 'https://example.com',
name: 'My Site',
// ...etc
},
})
If you have other environments, such as a staging or testing site, then it's recommended to set your site config using environment variables.
NUXT_SITE_URL=https://test.example.com
NUXT_SITE_NAME="STAGING SITE NAME"
NUXT_SITE_ENV="staging"
If you need to set your site config programmatically, you can use the site-config:resolve hook.
export default defineNuxtConfig({
hooks: {
'site-config:resolve': (siteConfig) => {
if (process.env.FOO)
siteConfig.name = 'Bar'
},
},
})
Sometimes you need to set your site config programmatically. This is fully supported, see the Runtime Site Config guide to learn how.