Newsletter
Join the Community
Subscribe to our newsletter for the latest news and updates
Dynamically generate `_headers` and `_redirects` files for Netlify in your Nuxt.js projects.
Nuxt Netlify is a Nuxt.js build module that automatically generates Netlify _headers and _redirects files from a netlify configuration object in your nuxt.config.js. It works at build time, so every deployment gets the headers and redirect rules you've defined without touching Netlify's dashboard or maintaining separate files.
Nuxt Netlify is a development tool for Nuxt.js projects (version 2 or newer) published on npm as @aceforth/nuxt-netlify. It takes a netlify config object from your Nuxt config as input and produces two output files: _headers and _redirects, placed in your build directory for Netlify to read. The module is maintained by juliomrqz and supports both redirect rules and header rules, including custom security headers, basic auth, rewrites, and country-based redirect conditions.
_headers and _redirects during nuxt build, so you never hand-edit these Netlify files./_nuxt/*, and no-cache for /sw.js.Access-Control-Allow-Origin header or a custom X-Build header.from, to, HTTP status codes (301, 302, 404, 200), force overrides, query string forwarding, and request conditions such as Country matching./_nuxt/* cache header automatically follows your build.publicPath setting in Nuxt config.buildModules (or modules for Nuxt before 2.9.0).force when Netlify already has a rule that would otherwise win.conditions with Country codes like cn,hk,tw to send visitors to country-specific pages (e.g. redirect / to /china).index.html with a 200 status so client-side routing works without 404s.Cache-Control on hashed /_nuxt/* assets and disable caching for the service worker.First install it with npm or yarn as a dev dependency, then add it to the buildModules array in nuxt.config.js. The module reads the netlify key from your config, merges the provided headers and redirects with its defaults, and writes _headers and _redirects into the build output. The default config already produces useful caching and security headers without any extra setup.
Nuxt Netlify requires Node version 10 or newer and Nuxt version 2 or newer. If you're using Nuxt before 2.9.0, you must add the module under modules instead of buildModules.
No. The module is open source and released under the MIT License. You can use it in personal and commercial projects freely, and the repository on GitHub is publicly accessible.
Yes. When you pass custom headers, they are appended to the defaults. There's a mergeSecurityHeaders option you can set to control merging behavior; the README's default example sets it to true.
Netlify processes the generated _headers and _redirects files at deploy time, just like files you'd upload manually. So rules you generate can combine with dashboard settings; any conflicts follow Netlify's precedence rules.
The README shows examples using 301, 302, 404, and 200. The 404 entry lets you respond with a custom 404 page, and the 200 entry is used as a rewrite.
