Newsletter
Join the Community
Subscribe to our newsletter for the latest news and updates
Secure and easy Axios integration for Nuxt 2, with automatic base URLs, token management, and SSR support.
@nuxtjs/axios is a Nuxt 2 module that brings Axios HTTP client into Nuxt applications, automating base URL configuration, global token management, and SSR request handling.
@nuxtjs/axios is an open-source module from the Nuxt Community, published under the MIT License, that integrates the Axios promise-based HTTP client into Nuxt 2 projects. It takes a Nuxt app configuration and injects a $axios instance available throughout the app, so you can make API calls without manually setting up base URLs or headers. The module runs on Nuxt 2 and is distributed through npm.
setToken function — The injected $axios exposes a setToken method to set authentication tokens globally; the token is then attached to all subsequent requests.withCredentials auto-enable — Automatically enables withCredentials when making requests to the configured base URL, which sends cookies along with the request.$axios.$get and $axios.$post in addition to the standard Axios API.setToken call to apply authentication tokens across all API requests.this.$axios.setToken('your-token') and every request automatically includes the token in its headers.$axios inside asyncData, fetch, or nuxtServerInit to retrieve data on the server with the correct base URL and forwarded headers.Yes, @nuxtjs/axios is open source under the MIT License, so it can be used in personal and commercial projects without licensing fees.
No, the module description explicitly targets Nuxt 2. For Nuxt 3 you would use Nuxt's native fetch or a different module; @nuxtjs/axios itself does not support Nuxt 3.
You install it as an npm package and add it to the modules array in your nuxt.config.js. The official documentation at axios.nuxtjs.org provides the exact setup steps and options.
Yes, the feature list includes auto retry for requests using axios-retry, so intermittent failures can be retried automatically without extra code on your part.
