|
| 1 | +import { createMetadata, Callout, CodeBlock, Tabs, TabsContent, TabsList, TabsTrigger, } from "@doc"; |
| 2 | + |
| 3 | +export const metadata = createMetadata({ |
| 4 | + image: { |
| 5 | + title: "Guest Mode", |
| 6 | + icon: "wallets", |
| 7 | + }, |
| 8 | + title: "Guest Mode", |
| 9 | + description: |
| 10 | + "Learn how to get users started in thirdweb wallets without requiring sign-in.", |
| 11 | +}); |
| 12 | + |
| 13 | +# Guest Mode |
| 14 | + |
| 15 | +Sometimes users want to get started using your app without signing in. You can now give users an in-memory "guest account" that can then be converted into a standard account by linking another auth method. |
| 16 | + |
| 17 | +<Callout variant='info' title="Guest Mode Support"> |
| 18 | + Guest mode is supported in both Ecosystem Wallets and In-App Wallets. |
| 19 | + |
| 20 | + The examples below show how to use Guest Mode with In-App Wallets, but the same principles apply to Ecosystem Wallets. |
| 21 | +</Callout> |
| 22 | + |
| 23 | +<Tabs defaultValue={"typescript"}> |
| 24 | + <TabsList> |
| 25 | + <TabsTrigger value="typescript">typescript</TabsTrigger> |
| 26 | + <TabsTrigger value="react">react/react native</TabsTrigger> |
| 27 | + <TabsTrigger value="dotnet">.NET</TabsTrigger> |
| 28 | + </TabsList> |
| 29 | + <TabsContent value="typescript"> |
| 30 | + <CodeBlock code={`import { inAppWallet } from "thirdweb/wallets"; |
| 31 | +const wallet = inAppWallet(); |
| 32 | +
|
| 33 | +// Create the temporary guest account |
| 34 | +const account = await wallet.connect({ |
| 35 | + client, |
| 36 | + strategy: "guest", |
| 37 | +});`} lang="typescript" /> |
| 38 | + </TabsContent> |
| 39 | + <TabsContent value="react"> |
| 40 | + <CodeBlock code={` |
| 41 | +import { ConnectButton } from "thirdweb/react"; |
| 42 | +import { inAppWallet } from "thirdweb/wallets"; |
| 43 | +
|
| 44 | +<ConnectButton |
| 45 | + wallets={[ |
| 46 | + inAppWallet({ |
| 47 | + auth: { |
| 48 | + options: ["google", "discord", "telegram", "email", "phone", "guest"], |
| 49 | + }, |
| 50 | + }), |
| 51 | + ]} |
| 52 | +/>;`} lang="jsx" /> |
| 53 | + </TabsContent> |
| 54 | + <TabsContent value="dotnet"> |
| 55 | + <CodeBlock code={`var wallet = await InAppWallet.Create(client: client, authProvider: AuthProvider.Guest); |
| 56 | +var address = await wallet.LoginWithGuest();`} lang="csharp" /> |
| 57 | + </TabsContent> |
| 58 | +</Tabs> |
| 59 | + |
| 60 | + |
| 61 | +When your user is ready, [link any other auth method](/connect/in-app-wallet/guides/link-multiple-profiles) so they can access their account in the future. |
| 62 | + |
| 63 | +<Tabs defaultValue={"typescript"}> |
| 64 | + <TabsList> |
| 65 | + <TabsTrigger value="typescript">typescript/react/react-native</TabsTrigger> |
| 66 | + <TabsTrigger value="dotnet">.NET</TabsTrigger> |
| 67 | + </TabsList> |
| 68 | + <TabsContent value="typescript"> |
| 69 | + <CodeBlock code={`import { linkProfile } from "thirdweb/wallets"; |
| 70 | +
|
| 71 | +await linkProfile(wallet, { strategy: "google" });`} lang="typescript" /> |
| 72 | + </TabsContent> |
| 73 | + <TabsContent value="dotnet"> |
| 74 | + <CodeBlock code={`var socialWallet = await InAppWallet.Create(client: client, authProvider: AuthProvider.Telegram); |
| 75 | +_ = await inAppWalletMain.LinkAccount(walletToLink: socialWallet,);`} lang="csharp" /> |
| 76 | + </TabsContent> |
| 77 | +</Tabs> |
| 78 | + |
| 79 | +Your user can now access this same wallet with their Google account. |
| 80 | + |
| 81 | +While it is not linked to any other identity, the lifetime of the guest wallet for any given user will last until they clear their browser storage. |
| 82 | + |
| 83 | +You can try out Guest Mode [on our playground.](https://playground.thirdweb.com/connect/sign-in/button) |
0 commit comments