Registry / storage / axios-cookiejar-support

axios-cookiejar-support

JSON →
library7.0.0jsnpmunverified

Add tough-cookie support to axios, allowing automatic cookie management in axios requests. Version 7.0.0 requires Node >=22.0.0 and axios >=0.20.0. Released as ESM-only, ships TypeScript types. Key differentiator: integrates tough-cookie's CookieJar directly into axios by wrapping the instance, supporting custom cookie jars for session persistence. Uses http-cookie-agent under the hood.

npm install axios-cookiejar-support
INSTALL
IMPORT
SIG · AXIOS-COOKIEJAR-SU
A
axios-cookiejar-support
storagejavascriptv7.0.0
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.

wrapper
import { wrapper } from 'axios-cookiejar-support'
const { wrapper } = require('axios-cookiejar-support')
ESM-only since v7; CJS require may fail or require .default
default import
import axiosCookiejarSupport from 'axios-cookiejar-support'
const axiosCookiejarSupport = require('axios-cookiejar-support')
Default export may be undefined in some versions; prefer named exports.
CookieJar
import { CookieJar } from 'tough-cookie'
import { CookieJar } from 'axios-cookiejar-support'
CookieJar is from tough-cookie, not from this package.

Shows how to add a CookieJar to an axios instance and use it to manage cookies automatically.

import axios from 'axios'; import { wrapper } from 'axios-cookiejar-support'; import { CookieJar } from 'tough-cookie'; const jar = new CookieJar(); const client = wrapper(axios.create({ jar })); (async () => { try { const response = await client.get('https://httpbin.org/cookies/set?foo=bar'); console.log('Cookies after set:', jar.getCookiesSync('https://httpbin.org')); } catch (err) { console.error(err); } })();
Debug
Known issues
breakingVersion 7.0.0 drops CommonJS support; only ESM is provided.
fix
Use ESM imports (import { wrapper } from 'axios-cookiejar-support'). If you need CJS, pin to ^6.0.0.
affects: >=7.0.0
breakingNode.js >=22.0.0 is required in v7.0.0.
fix
Upgrade Node to v22+ or downgrade to v6.x.
affects: >=7.0.0
gotchaThe wrapper uses httpAgent/httpsAgent internally; assigning custom agents may break cookie handling.
fix
To use a custom agent (e.g., http-proxy-agent), consider using http-cookie-agent directly instead.
affects: *
deprecatedThe 'jar' option in axios request config is deprecated in favor of attaching jar to the instance config.
fix
Pass jar in axios.create({ jar }) rather than per-request.
affects: >=5.0.0
gotchaThe package does not export types; you must install tough-cookie types separately for TypeScript.
fix
Run npm install --save-dev @types/tough-cookie.
affects: *
Errors
Common errors & fixes
SyntaxError: Named export 'wrapper' not found. The requested module 'axios-cookiejar-support' is a CommonJS module, which may not support all module.exports as named exports.
Trying to import named export from CJS version using ESM syntax, or vice versa.
fix
Ensure you are using ESM (import) with v7+ or CJS (require) with v6.x.
TypeError: Cannot read properties of undefined (reading 'cookie')
Missing CookieJar instance or incorrect jar attachment.
fix
Make sure to create a CookieJar and pass it to wrapper(axios.create({ jar })).
Error: Cannot find module 'tough-cookie'
tough-cookie is not installed as a peer dependency.
fix
Run npm install axios tough-cookie axios-cookiejar-support.
Upgrade
Version history
7.0.0latest on npm
Audit
Dependencies
axiosrequiredpeer dependency - works with axios >=0.20.0
tough-cookierequiredpeer dependency - CookieJar is required for cookie storage
Agent activity
54 hits · last 30 days
node
48
OpenAI (training)
1
Resources
axios-cookiejar-support — npm install axios-cookiejar-support · libregistry