> ## Documentation Index
> Fetch the complete documentation index at: https://docs.dynamic.xyz/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# useExternalAuth

<Card title="Recommended: JavaScript SDK with React Hooks" icon="react" color="#4779FE">
  For new React apps, we recommend the JavaScript SDK with React Hooks (`@dynamic-labs-sdk/react-hooks`) instead of the legacy React SDK documented here. The JS SDK comes with many benefits such as a much smaller bundle size and other optimizations. Use the [React quickstart (JavaScript SDK)](/javascript/reference/react-quickstart) to get started.
</Card>

<Note>
  ### This is an enterprise-only feature. Please contact us if you are interested.
</Note>

### Summary

This hook provides a way for clients to sign-in to Dynamic or link with Dynamic using a third-party issued JWT auth token.

The hook needs to be initialized within a child of [DynamicContextProvider](/react/reference/providers/dynamiccontextprovider).

### Usage

Available methods:

* `signInWithExternalJwt`: Sign in to Dynamic by providing the external user ID and JWT. This will automatically set the logged-in Dynamic `user` when successful.

### Usage

```TypeScript theme={"system"}
const { signInWithExternalJwt } = useExternalAuth();

try {
  // `externalUserId`: User ID in the external auth system
  // `externalJwt`: Raw encoded JWT issued by external auth system
  const userProfile = await signInWithExternalJwt({
    externalUserId,
    externalJwt
  });

  if (userProfile) {
    // You should be logged in at this point
  }
} catch (e: any) {
  console.error('Dynamic login failed:', e);
}
```

### Details

In order to use this hook, the proper [external auth settings](/overview/authentication/bring-your-own-auth) need to be configured.
