@arunpradeepvn/jwt-utility
v1.0.7
Published
A simple utility for decoding JWT tokens.
Downloads
26
Maintainers
Readme
JWT Utility
A simple utility for decoding JWT (JSON Web Tokens) in TypeScript.
Supported in Expo, React Native, React.js and Node.js.
Installation
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
Usage
Importing the Utility
You can import the decodeJWT function from the package:
import { decodeJWT } from '@arunpradeepvn/jwt-utility';
Decoding a JWT
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);
}
API
decodeJWT(token: string): Record<string, any>
token: A JWT string to decode.
Returns: The decoded payload as a JSON object.