# @nextcloud/axios

> Axios client for Nextcloud

Latest version **2.6.0** (published 2026-04-21) · GPL-3.0-or-later license · 0 weekly downloads

## Install

```sh
npm install @nextcloud/axios
pnpm add @nextcloud/axios
yarn add @nextcloud/axios
bun add @nextcloud/axios
```

## Health

**Score 70/100 (B)** — status: stable.

Positive: has types; esm support; no vulnerabilities; has provenance; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 2.6.0 |
| Published | 2026-04-21 |
| First published | 2019-10-02 |
| Weekly downloads | 0 |
| License | GPL-3.0-or-later |
| TypeScript types | bundled |
| Module format | ESM |
| Node | ^20.0.0 \|\| ^22.0.0 \|\| ^24.0.0 |
| Dependencies | 2 |
| Unpacked size | 53.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 9 |
| Author | Nextcloud GmbH and Nextcloud contributors |
| Maintainers | icewind1991, skjnldsv, christophwurst, juliushaertl, nickvergessen, artonge, gretadoci, mejo-, susnux |
| Keywords | nextcloud, http, axios, csrf |

## Links

- npm: https://www.npmjs.com/package/@nextcloud/axios
- Repository: https://github.com/nextcloud-libraries/nextcloud-axios
- Homepage: https://github.com/nextcloud-libraries/nextcloud-axios#readme
- Issues: https://github.com/nextcloud-libraries/nextcloud-axios/issues
- npm.io page: https://npm.io/package/@nextcloud/axios

## Dependencies (2)

- [axios](https://npm.io/package/axios.md) ^1.15.0
- [@nextcloud/auth](https://npm.io/package/@nextcloud/auth.md) ^2.6.0

## Alternatives

- [launchdarkly-js-client-sdk](https://npm.io/package/launchdarkly-js-client-sdk.md) — 2.5M weekly downloads
- [@elastic/elasticsearch](https://npm.io/package/@elastic/elasticsearch.md) — 2.1M weekly downloads
- [@c8y/client](https://npm.io/package/@c8y/client.md) — 15.3K weekly downloads
- [@signaldb/maverickjs](https://npm.io/package/@signaldb/maverickjs.md) — 1.7K weekly downloads
- [@bbc/http-transport-cache](https://npm.io/package/@bbc/http-transport-cache.md) — 1.2K weekly downloads

## Recent versions

- 2.6.0 (latest) — 2026-04-21
- 2.4.0-rc1 (next) — 2023-04-21
- 2.5.2 — 2025-09-20
- 2.5.1 — 2024-09-18
- 2.5.0 — 2024-04-30
- 2.4.0 — 2023-07-03
- 2.3.0 — 2022-12-16
- 2.2.0 — 2022-11-24
- 2.1.0 — 2022-10-01
- 2.0.0 — 2022-08-11
- 1.11.0 — 2022-08-10
- 1.10.0 — 2022-04-28
- 1.9.0 — 2022-01-18
- 1.8.0 — 2021-11-26
- 1.7.0 — 2021-09-28
- … 14 more at https://npm.io/package/@nextcloud/axios/versions

## README

<!--
  - SPDX-FileCopyrightText: 2018-2024 Nextcloud GmbH and Nextcloud contributors
  - SPDX-License-Identifier: GPL-3.0-or-later
-->
# @nextcloud/axios
[![REUSE status](https://api.reuse.software/badge/github.com/nextcloud-libraries/nextcloud-axios)](https://api.reuse.software/info/github.com/nextcloud-libraries/nextcloud-axios)
[![Build Status](https://img.shields.io/github/actions/workflow/status/nextcloud-libraries/nextcloud-axios/node-test.yml?branch=master)](https://github.com/nextcloud-libraries/nextcloud-axios/actions/workflows/node-test.yml?query=branch%3Amaster)
[![npm](https://img.shields.io/npm/v/@nextcloud/axios.svg)](https://www.npmjs.com/package/@nextcloud/axios)
[![code coverage](https://img.shields.io/codecov/c/github/nextcloud-libraries/nextcloud-axios)](https://app.codecov.io/gh/nextcloud-libraries/nextcloud-axios)


Simple, typed wrapper of an Axios instance for Nextcloud that automatically sends authentication headers. [Cancellation](https://github.com/axios/axios#cancellation) is supported as well.

## Installation

```sh
npm install @nextcloud/axios --save
```

```sh
yarn add @nextcloud/axios
```

## Usage

```js
import axios from '@nextcloud/axios'

axios.get('nextcloud.com')
```

See https://github.com/axios/axios for details.

### Defining `baseURL`

You are able to define [`baseURL`](https://axios-http.com/docs/config_defaults) to simplify the usage of axios across your app.

```ts
import axios from '@nextcloud/axios'
import { generateUrl } from '@nextcloud/router'

const baseURL = generateUrl('/apps/your_app_id/api')

axios.defaults.baseURL = baseURL
```

### Retry handling

This package can optionally retry requests if they fail due to Nextcloud's *maintenance mode*. To activate this feature, pass
`retryIfMaintenanceMode: true` into the request options. This mechanism will only catch relatively short server maintenance
downtime in the range of seconds to a minute. Any longer downtime still has to be handled by the application, show feedback
to the user, reload the page etc.

```js
import axios from '@nextcloud/axios'

const pizzas = await axios.get('/apps/pizza/api/pizzas', {
    retryIfMaintenanceMode: true,
})
const myPizza = await axios.post('/apps/pizza/api/pizzas', { toppings: ['pineapple'] }, {
    retryIfMaintenanceMode: true,
})
```

### Expired sessions handling

This package can optionally trigger a page reload whenever a request fails due to an expired user session. This interrupts
application logic and should be the last resort. If possible, handle the expired session higher up in the application.

```js
import axios from '@nextcloud/axios'

const response = await axios.get('/apps/foo/api/bar', {
    reloadExpiredSession: true,
})
```

References

- [@nextcloud/router](https://github.com/nextcloud/nextcloud-router)
- [Nextcloud App Routing](https://docs.nextcloud.com/server/latest/developer_manual/basics/routing.html)

---
_Source: https://npm.io/package/@nextcloud/axios · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
