Newsletter
Join the Community
Subscribe to our newsletter for the latest news and updates
Universal HTTP Module for Nuxt.js
Nuxt HTTP is a Nuxt module that provides a universal, isomorphic HTTP client for Nuxt.js 2 applications, giving server-side and client-side code a single API for requesting backend services. Built and maintained by the Nuxt.js Team, it wraps the fluent ky HTTP library and adds Nuxt-specific enhancements.
Nuxt HTTP is an official Nuxt module that adds an $http instance to your Nuxt app, using the ky API extended with Nuxt shortcuts. It accepts configuration options like a BaseURL and automatically handles the environment (server or client) so the same request syntax works everywhere. The module only supports Nuxt 2; Nuxt 3 projects should use the built-in isomorphic $fetch API instead.
Nuxt HTTP is for Nuxt 2 developers who need a consistent HTTP client across client and server rendering. It suits API-driven applications, SSR projects that must forward authentication cookies, and teams already using ky and wanting tight Nuxt integration.
asyncData, server middleware, or client code with the same $http method.Install the module via yarn and add it to the modules array in your Nuxt config. Then call $http anywhere in your app — on client or server — and the module maps it to the right environment, applying your BaseURL and proxy settings automatically. For development, clone the repo, run yarn install, and start the dev server with yarn dev to see the example at http://localhost:3000/mounted.
No, Nuxt HTTP supports Nuxt 2 only. For Nuxt 3, use the built-in isomorphic $fetch API, which is available globally and covers most of the same use cases.
Nuxt HTTP is built on top of ky, a modern and lightweight HTTP client, and extends its API with Nuxt-specific conveniences.
Use yarn or npm to install @nuxt/http, then add it to the modules section of your nuxt.config.js file. Documentation is available at http.nuxtjs.org.
