Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

nuxt-3-axios

Axios in Nuxt 3

nuxt, nuxt3, axios, typesafe, isomorphic http, ssr, vue, tajikistan

readme

Axios in Nuxt 3

npm version npm downloads License Nuxt

Axios in Nuxt 3 with batteries included for doing amazing things.

Features

Now you can get typed axios instance inside your nuxt app from Nuxt context

nuxt.config.ts

export default defineNuxtConfig({
  modules: [
    'nuxt-3-axios'
  ],
  axios:{
    baseURL: 'https://swapi.dev/api/'
    //options to pass Axios Config
  }
})

Axios config options here!

Example.vue

const { $axios } = useNuxtApp() 

const result = await $axios.get('/people/1')

// result =  {
//     "name": "Luke Skywalker",
// }

Quick Setup

  1. Add nuxt-3-axios dependency to your project
# Using pnpm
pnpm add -D nuxt-3-axios

# Using yarn
yarn add --dev nuxt-3-axios

# Using npm
npm install --save-dev nuxt-3-axios
  1. Add nuxt-3-axios to the modules section of nuxt.config.ts
export default defineNuxtConfig({
  modules: [
    'nuxt-3-axios'
  ],
  axios:{
    //options to pass to axios create https://axios-http.com/docs/instance
    baseURL: 'https://swapi.dev/api/'
  }
})

That's it! You can now use Axios in Nuxt 3 in your app ✨

Development

# Install dependencies
npm install

# Generate type stubs
npm run dev:prepare

# Develop with the playground
npm run dev

# Build the playground
npm run dev:build

# Run ESLint
npm run lint

# Run Vitest
npm run test
npm run test:watch

# Release new version
npm run release

changelog

Changelog

v1.3.5

compare changes

✅ Tests

🎨 Styles

❤️ Contributors

  • Farid

v1.3.4

compare changes

v1.3.3

compare changes

🏡 Chore

❤️ Contributors

  • Farid

v1.3.2

compare changes

🩹 Fixes

❤️ Contributors

  • Farid

v1.3.1

compare changes

🏡 Chore

❤️ Contributors

  • Farid

v1.3.0

compare changes

🚀 Enhancements

  • Add axios pluging in module + types (a90b845)

🏡 Chore

❤️ Contributors

  • Farid

v1.2.1

compare changes

v1.2.0

🚀 Enhancements

  • Replace path with createResolver (#162)

🩹 Fixes

  • Update type from Boolean -> boolean (5340e5b)
  • Add package.json to workaround vite+windows resolution issue (#8)
  • Add @nuxt/schema to dev-dependencies (#99)
  • types: Include src and playground in tsconfig (#163)
  • Temporarily revert include pending further testing (41a888a)
  • Include workspace in tsconfig.json (94e0f8c)
  • Use path to module, fixing auto-generated types (f6affff)
  • Add node16 compatible type declaration (c16b320)

💅 Refactors

  • Import types with module import (724b76f)

📖 Documentation

  • Update readme (9475ed2)
  • Add nuxt badge (171b34a)
  • Simplify logo (3a4af4e)

🏡 Chore

  • Update play script to dev (7c10e32)
  • Update prepare script due to issue with npm publish (26df694)
  • Exclude recommended vscode files from gitignore (#155)
  • Update module template (#216)
  • Typo (83c8952)
  • Fix typo (#225)
  • Bump to v3.1.2 (bbb23c5)
  • Fix release script (#237)
  • package: Add repository field (607c3e0)
  • Add playground (040e46d)
  • Fix typo (#293)

❤️ Contributors