Registry / devops / axios-tauri-api-adapter

axios-tauri-api-adapter

JSON →
library2.0.6jsnpmunverified

An Axios adapter for Tauri v2 apps that bridges browser-style HTTP requests with Tauri's HTTP plugin. Version 2.0.6 targets Tauri 2.0.0+ and requires Node >=16. It wraps Tauri's fetch API, allowing Axios usage with its full interceptor/transformer pipeline inside Tauri webviews. Unlike raw Tauri HTTP calls, this adapter provides Axios convenience features like request/response interceptors, automatic JSON parsing, and JWT header injection via config.jwt. Release cadence is irregular; the v1 branch supports Tauri 1.x.

npm install axios-tauri-api-adapter
INSTALL
IMPORT
SIG · AXIOS-TAURI-API-AD
A
axios-tauri-api-adapter
devopsjavascriptv2.0.6
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import axiosTauriApiAdapter from 'axios-tauri-api-adapter'
const axiosTauriApiAdapter = require('axios-tauri-api-adapter')
ESM-only; no default CommonJS require.
axiosTauriApiAdapter
import axiosTauriApiAdapter from 'axios-tauri-api-adapter'
import { axiosTauriApiAdapter } from 'axios-tauri-api-adapter'
Default export, not named.
AxiosRequestConfig
import type { AxiosRequestConfig } from 'axios'
Type imports come from axios, not this adapter.

Shows how to create an Axios instance with the Tauri adapter and make a GET request with JWT.

import axios from 'axios'; import axiosTauriApiAdapter from 'axios-tauri-api-adapter'; const client = axios.create({ adapter: axiosTauriApiAdapter, baseURL: process.env.API_URL ?? 'https://api.example.com' }); async function fetchData() { try { const response = await client.get('/data', { params: { id: 123 }, jwt: 'your-jwt-token' // automatically added as Authorization header }); console.log(response.data); } catch (error) { console.error(error); } } fetchData();
Debug
Known issues
gotchaAdapter works only inside Tauri v2 webview; will throw in Node.js or browser outside Tauri.
fix
Use only in Tauri app; for testing, mock the adapter.
affects: >=2.0.0
breakingv2 is incompatible with Tauri v1; use v1 branch for Tauri 1.x.
fix
Use axios-tauri-api-adapter@1 for Tauri v1 apps.
affects: >=2.0.0
gotchaMust configure Tauri HTTP permissions in tauri.conf.json to allow target URLs.
fix
Add 'http:default' permission with allow/deny lists in capabilities.
affects: >=2.0.0
deprecatedconfig.jwt is a non-standard Axios config; may conflict with standard headers.
fix
Use standard headers Authorization instead if custom JWT handling is not needed.
affects: >=2.0.0
Errors
Common errors & fixes
Uncaught TypeError: adapter is not a function
Importing the adapter incorrectly (e.g., named import instead of default).
fix
Use import axiosTauriApiAdapter from 'axios-tauri-api-adapter'
Error: The 'adapter' option is not supported in this environment
Running outside Tauri (e.g., in Node.js or browser).
fix
Run only inside a Tauri v2 webview, or conditionally apply adapter with isTauri() check.
Uncaught (in promise) Error: Failed to send request: http:://... not allowed
Tauri HTTP permission not configured for the target URL.
fix
Add the URL pattern to 'allow' list in capabilities under 'http:default'.
Upgrade
Version history
2.0.6latest on npm
Audit
Dependencies
axiosrequiredpeer dependency; the adapter is used to create an Axios instance.
@tauri-apps/plugin-httprequiredrequired to use Tauri's HTTP plugin; must be installed separately.
Agent activity
13 hits · last 30 days
node
10
OpenAI (training)
2
Resources
axios-tauri-api-adapter — npm install axios-tauri-api-adapter · libregistry