A simple utility for decoding JWT (JSON Web Tokens) in TypeScript.
Supported in Expo, React Native, React.js and Node.js.
You can install the package via npm:
npm install @arunpradeepvn/jwt-utility@latest
You can install the package via yarn:
yarn add @arunpradeepvn/jwt-utility@latest
You can import the decodeJWT function from the package:
import { decodeJWT } from '@arunpradeepvn/jwt-utility';
To decode a JWT, use the decodeJWT function:
const token = 'YOUR_JWT_TOKEN_HERE';
try {
const decoded = await decodeJWT(token);
console.log(decoded);
} catch (error) {
console.error('Failed to decode token:', error);
}
decodeJWT(token: string): Record<string, any>
token: A JWT string to decode.
Returns: The decoded payload as a JSON object.