Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
changeset
  • Loading branch information
ikethirdweb committed Oct 20, 2023
commit 7c1002cedff87b959ed9c59f5a1e0eec969320cc
58 changes: 58 additions & 0 deletions .changeset/cold-dryers-dream.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
"@thirdweb-dev/react-native": patch
---

Custom JWT support in React Native

Enables passing a custom JWT to the embeddedWallet:

```javascript
import {
EmbeddedWallet,
embeddedWallet,
ThirdwebProvider,
useCreateWalletInstance,
useSetConnectedWallet,
} from '@thirdweb-dev/react-native';
import {Button} from 'react-native';
import React from 'react';

const App = () => {
return (
<ThirdwebProvider
supportedWallets={[
embeddedWallet({
custom_auth: true, // when true, it will not display a UI
}),
]}>
<AppInner />
</ThirdwebProvider>
);
};

const AppInner = () => {
const createInstance = useCreateWalletInstance();
const setConnectedWallet = useSetConnectedWallet();

const triggerConnect = async () => {
const embeddedWalletConfig = embeddedWallet();

if (embeddedWalletConfig) {
const instance = createInstance(embeddedWalletConfig);

if (instance) {
await (instance as EmbeddedWallet).connect({
loginType: 'custom_jwt_auth',
encryptionKey: 'hello',
jwtToken: 'customJwt' || '',
});
setConnectedWallet(instance); // this sets the active wallet on the provider enabling all thirdweb hooks
}
}
};

return <Button title={'Connect with custom JWT'} onPress={triggerConnect} />;
};


```