Documentation Index
Fetch the complete documentation index at: https://docs.cloud.coinbase.com/llms.txt
Use this file to discover all available pages before exploring further.
function useAuthenticateWithJWT(): {
authenticateWithJWT: (options?: {
idempotencyKey?: string;
}) => Promise<AuthenticateWithJWTResult>;
};
Hook that provides access to authenticate end users with developer-issued JWTs.
Use this when integrating with third-party identity providers (Auth0, Firebase, Cognito, etc.).
Important: Before using this hook, you must:
- Configure custom auth in the CDP Portal (JWKS endpoint, issuer, etc.)
- Provide a
customAuth.getJwt callback in your CDP initialization config
Returns
{
authenticateWithJWT: (options?: {
idempotencyKey?: string;
}) => Promise<AuthenticateWithJWTResult>;
}
| Name | Type |
|---|
authenticateWithJWT() | (options?: { idempotencyKey?: string; }) => Promise<AuthenticateWithJWTResult> |
Examples
// React - With Auth0
import { useAuth0 } from '@auth0/auth0-react';
import { useAuthenticateWithJWT } from '@coinbase/cdp-hooks';
function AuthButton() {
const { getAccessTokenSilently } = useAuth0();
const { authenticateWithJWT } = useAuthenticateWithJWT();
const [error, setError] = useState(null);
const handleLogin = async () => {
try {
// Authenticate with CDP (uses customAuth.getJwt callback)
const { user, isNewUser } = await authenticateWithJWT();
console.log('Authenticated user:', user);
if (isNewUser) {
console.log('New user created with wallet!');
}
} catch (err) {
setError(err.message);
}
};
return (
<div>
<button onClick={handleLogin}>Sign In with Auth0</button>
{error && <p>Error: {error}</p>}
</div>
);
}
// React Native - With Auth0
import { useAuth0 } from 'react-native-auth0';
import { useAuthenticateWithJWT } from '@coinbase/cdp-hooks';
import { Button, Text, View } from 'react-native';
function AuthScreen() {
const { authorize } = useAuth0();
const { authenticateWithJWT } = useAuthenticateWithJWT();
const [error, setError] = useState(null);
const handleLogin = async () => {
try {
// Step 1: Trigger Auth0 login (opens browser)
await authorize();
// Step 2: Authenticate with CDP
const { user, isNewUser } = await authenticateWithJWT();
console.log('Authenticated user:', user);
if (isNewUser) {
console.log('New user created with wallet!');
}
} catch (err) {
setError(err.message);
}
};
return (
<View>
<Button title="Sign In with Auth0" onPress={handleLogin} />
{error && <Text>Error: {error}</Text>}
</View>
);
}