Skip to content

Commit

Permalink
docs: v2 beta migration guide (#1696)
Browse files Browse the repository at this point in the history
* chore: add beta tag to release script

* chore: migration guide scaffold

* chore: copy guide from @mago/v2-docs-changesets

* chore: sitemap update

* Revert "chore: temporarily remove generated-test-app"

This reverts commit 3303207.

* chore: guide improvements

* chore: docs cleanup

* chore: tweaks

* chore: remove beta note

* chore: tweak diffs

* chore: tweak

* chore: remove wagmi provider in example

* fix: broken title

* chore: subsections

* fix: rainbowkit diff title

* fix: subheader prominence

* chore: tweaks

* chore: tweaks
  • Loading branch information
DanielSinclair authored Jan 11, 2024
1 parent 9d4e9ac commit d2ed284
Show file tree
Hide file tree
Showing 3 changed files with 204 additions and 0 deletions.
203 changes: 203 additions & 0 deletions site/data/en-US/guides/rainbowkit-wagmi-v2.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,203 @@
---
title: Upgrading your dApp for RainbowKit v2
description: RainbowKit and Wagmi have been promoted to v2
image: guide-rainbowkit-v2.png
---

# Migrating to RainbowKit and Wagmi v2

The [Wagmi](https://wagmi.sh) peer dependency has been updated to `2.x.x`.

> Note: RainbowKit v2 is currently in Beta. Please report any issues or feedback on GitHub [here](https://github.com/rainbow-me/rainbowkit/issues/new/choose).
Follow the steps below to migrate.

**1. Upgrade RainbowKit, `wagmi`, and `viem` to their latest versions**

```bash
npm i @rainbow-me/rainbowkit@beta wagmi@2 viem@2
```


**2. Install `@tanstack/react-query` peer dependency**

With Wagmi v2, [TanStack Query](https://tanstack.com/query/v5/docs/react/overview) is now a required peer dependency.

Install it with the following command:

```bash
npm i @tanstack/react-query
```


**3. Adjust your Wagmi and RainbowKit configuration**

```diff
+ import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
- import { configureChains, WagmiConfig } from 'wagmi'
- import { publicProvider } from 'wagmi/providers/public'
+ import { WagmiProvider } from 'wagmi'
import { mainnet, sepolia } from 'wagmi/chains'
+ import { getDefaultConfig } from '@rainbow-me/rainbowkit';

- const projectId = "YOUR_PROJECT_ID";

- const { chains, publicClient } = configureChains(
- [mainnet, sepolia],
- [publicProvider()],
- );

- const { connectors } = getDefaultWallets({
- appName: 'RainbowKit App',
- projectId,
- chains,
- });

- const config = createConfig({
- autoConnect: true,
- publicClient
- connectors,
});

/* New RainbowKit API */
const config = getDefaultConfig({
appName: "My RainbowKit App",
projectId: "YOUR_PROJECT_ID",
chains: [mainnet, sepolia],
});

+ const queryClient = new QueryClient();

const App = () => {
return (
- <WagmiConfig config={config}>
+ <WagmiProvider config={config}>
+ <QueryClientProvider client={queryClient}>
- <RainbowKitProvider chains={chains}>
+ <RainbowKitProvider>
{/* Your App */}
</RainbowKitProvider>
+ </QueryClientProvider>
+ </WagmiProvider>
- </WagmiConfig>
);
};
```


**4. Check for breaking changes in `wagmi` and `viem`**

If you use `wagmi` hooks and `viem` actions in your dApp, you will need to follow the migration guides for v2:

- [Wagmi v2 Migration Guide](https://wagmi.sh/react/guides/migrate-from-v1-to-v2)
- [Viem v2 Breaking Changes](https://viem.sh/docs/migration-guide.html#_2-x-x-breaking-changes)


**5. Check for breaking changes in RainbowKit**

#### getDefaultConfig

For dApps without a custom wallet list, `getDefaultConfig` will simplify your configuration. This replaces the need to use `getDefaultWallets`, `connectorsForWallets`, and Wagmi's `createConfig`.

You may still provide `wallets` from `getDefaultWallets` to `getDefaultConfig` alongside a custom Wallet List to build your own list, or use `connectorsForWallets` as needed. Reference the example below.

#### getDefaultWallets

You no longer need to provide paramaters to `getDefaultWallets` to receive a list of default wallets

```diff
- const { wallets } = getDefaultWallets({
- appName: 'RainbowKit demo',
- projectId,
- chains,
- });
+ const { wallets } = getDefaultWallets();
```

You do need to pass parameters to `getDefaultWallets` to receive prepared `connectors` for Wagmi's `createConfig`. The `chains` prop is no longer required.
```diff
const { connectors } = getDefaultWallets({
appName: 'RainbowKit demo',
projectId,
- chains,
});
```

#### Custom Wallet List

**connectorsForWallets**

If you've used wallets from `@rainbow-me/rainbowkit/wallets`, you no longer need to call each wallet and pass in `projectId`, `chains` or WalletConnect options.

You should now pass a 2nd parameter to `connectorsForWallets` with `appName`, `projectId` and additional optional props.

```diff
const connectors = connectorsForWallets([
...wallets,
{
groupName: 'Popular',
wallets: [
- ledgerWallet({ projectId, chains }),
+ ledgerWallet,
- trustWallet({ projectId, chains }),
+ trustWallet
],
},
+ {
+ appName,
+ projectId,
+ }
]);
```

**Deprecated wallets**
The follow wallet connectors are deprecated and no longer needed. Their functionality is now supported by RainbowKit by default.
- `injectedWallet`
- `safeWallet`
- `braveWallet`

**Example**

```diff
- const { wallets } = getDefaultWallets({
- appName: 'RainbowKit demo',
- projectId,
- chains,
- });
+ const { wallets } = getDefaultWallets();

+ const config = getDefaultConfig({
+ appName: "My RainbowKit App",
+ projectId: "YOUR_PROJECT_ID",
+ chains: [mainnet, sepolia],
+ wallets
+ });

// or you can use Wagmi's `createConfig()` directly

const connectors = connectorsForWallets([
...wallets,
{
groupName: 'Popular',
wallets: [
- ledgerWallet({ projectId, chains }),
- trustWallet({ projectId, chains }),
+ ledgerWallet,
+ trustWallet
],
},
+ {
+ appName,
+ projectId,
+ }
]);

const config = createConfig({
connectors,
+ chains: [mainnet, sepolia],
+ transports: {
+ [mainnet.id]: http(),
+ [sepolia.id]: http()
+ },
});
```
1 change: 1 addition & 0 deletions site/public/sitemap-0.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@
<url><loc>https://rainbowkit.com/docs/theming</loc><changefreq>daily</changefreq><priority>0.7</priority><xhtml:link rel="alternate" hreflang="en-US" href="https://rainbowkit.com/en-US/docs/theming"/><xhtml:link rel="alternate" hreflang="ar" href="https://rainbowkit.com/ar/docs/theming"/><xhtml:link rel="alternate" hreflang="es-419" href="https://rainbowkit.com/es-419/docs/theming"/><xhtml:link rel="alternate" hreflang="fr" href="https://rainbowkit.com/fr/docs/theming"/><xhtml:link rel="alternate" hreflang="hi" href="https://rainbowkit.com/hi/docs/theming"/><xhtml:link rel="alternate" hreflang="id" href="https://rainbowkit.com/id/docs/theming"/><xhtml:link rel="alternate" hreflang="ja" href="https://rainbowkit.com/ja/docs/theming"/><xhtml:link rel="alternate" hreflang="ko" href="https://rainbowkit.com/ko/docs/theming"/><xhtml:link rel="alternate" hreflang="pt-BR" href="https://rainbowkit.com/pt-BR/docs/theming"/><xhtml:link rel="alternate" hreflang="ru" href="https://rainbowkit.com/ru/docs/theming"/><xhtml:link rel="alternate" hreflang="th" href="https://rainbowkit.com/th/docs/theming"/><xhtml:link rel="alternate" hreflang="tr" href="https://rainbowkit.com/tr/docs/theming"/><xhtml:link rel="alternate" hreflang="ua" href="https://rainbowkit.com/ua/docs/theming"/><xhtml:link rel="alternate" hreflang="zh-CN" href="https://rainbowkit.com/zh-CN/docs/theming"/></url>
<url><loc>https://rainbowkit.com/docs/wallet-button</loc><changefreq>daily</changefreq><priority>0.7</priority><xhtml:link rel="alternate" hreflang="en-US" href="https://rainbowkit.com/en-US/docs/wallet-button"/><xhtml:link rel="alternate" hreflang="ar" href="https://rainbowkit.com/ar/docs/wallet-button"/><xhtml:link rel="alternate" hreflang="es-419" href="https://rainbowkit.com/es-419/docs/wallet-button"/><xhtml:link rel="alternate" hreflang="fr" href="https://rainbowkit.com/fr/docs/wallet-button"/><xhtml:link rel="alternate" hreflang="hi" href="https://rainbowkit.com/hi/docs/wallet-button"/><xhtml:link rel="alternate" hreflang="id" href="https://rainbowkit.com/id/docs/wallet-button"/><xhtml:link rel="alternate" hreflang="ja" href="https://rainbowkit.com/ja/docs/wallet-button"/><xhtml:link rel="alternate" hreflang="ko" href="https://rainbowkit.com/ko/docs/wallet-button"/><xhtml:link rel="alternate" hreflang="pt-BR" href="https://rainbowkit.com/pt-BR/docs/wallet-button"/><xhtml:link rel="alternate" hreflang="ru" href="https://rainbowkit.com/ru/docs/wallet-button"/><xhtml:link rel="alternate" hreflang="th" href="https://rainbowkit.com/th/docs/wallet-button"/><xhtml:link rel="alternate" hreflang="tr" href="https://rainbowkit.com/tr/docs/wallet-button"/><xhtml:link rel="alternate" hreflang="ua" href="https://rainbowkit.com/ua/docs/wallet-button"/><xhtml:link rel="alternate" hreflang="zh-CN" href="https://rainbowkit.com/zh-CN/docs/wallet-button"/></url>
<url><loc>https://rainbowkit.com/guides/rainbow-button</loc><changefreq>daily</changefreq><priority>0.7</priority><xhtml:link rel="alternate" hreflang="en-US" href="https://rainbowkit.com/en-US/guides/rainbow-button"/><xhtml:link rel="alternate" hreflang="ar" href="https://rainbowkit.com/ar/guides/rainbow-button"/><xhtml:link rel="alternate" hreflang="es-419" href="https://rainbowkit.com/es-419/guides/rainbow-button"/><xhtml:link rel="alternate" hreflang="fr" href="https://rainbowkit.com/fr/guides/rainbow-button"/><xhtml:link rel="alternate" hreflang="hi" href="https://rainbowkit.com/hi/guides/rainbow-button"/><xhtml:link rel="alternate" hreflang="id" href="https://rainbowkit.com/id/guides/rainbow-button"/><xhtml:link rel="alternate" hreflang="ja" href="https://rainbowkit.com/ja/guides/rainbow-button"/><xhtml:link rel="alternate" hreflang="ko" href="https://rainbowkit.com/ko/guides/rainbow-button"/><xhtml:link rel="alternate" hreflang="pt-BR" href="https://rainbowkit.com/pt-BR/guides/rainbow-button"/><xhtml:link rel="alternate" hreflang="ru" href="https://rainbowkit.com/ru/guides/rainbow-button"/><xhtml:link rel="alternate" hreflang="th" href="https://rainbowkit.com/th/guides/rainbow-button"/><xhtml:link rel="alternate" hreflang="tr" href="https://rainbowkit.com/tr/guides/rainbow-button"/><xhtml:link rel="alternate" hreflang="ua" href="https://rainbowkit.com/ua/guides/rainbow-button"/><xhtml:link rel="alternate" hreflang="zh-CN" href="https://rainbowkit.com/zh-CN/guides/rainbow-button"/></url>
<url><loc>https://rainbowkit.com/guides/rainbowkit-wagmi-v2</loc><changefreq>daily</changefreq><priority>0.7</priority><xhtml:link rel="alternate" hreflang="en-US" href="https://rainbowkit.com/en-US/guides/rainbowkit-wagmi-v2"/><xhtml:link rel="alternate" hreflang="ar" href="https://rainbowkit.com/ar/guides/rainbowkit-wagmi-v2"/><xhtml:link rel="alternate" hreflang="es-419" href="https://rainbowkit.com/es-419/guides/rainbowkit-wagmi-v2"/><xhtml:link rel="alternate" hreflang="fr" href="https://rainbowkit.com/fr/guides/rainbowkit-wagmi-v2"/><xhtml:link rel="alternate" hreflang="hi" href="https://rainbowkit.com/hi/guides/rainbowkit-wagmi-v2"/><xhtml:link rel="alternate" hreflang="id" href="https://rainbowkit.com/id/guides/rainbowkit-wagmi-v2"/><xhtml:link rel="alternate" hreflang="ja" href="https://rainbowkit.com/ja/guides/rainbowkit-wagmi-v2"/><xhtml:link rel="alternate" hreflang="ko" href="https://rainbowkit.com/ko/guides/rainbowkit-wagmi-v2"/><xhtml:link rel="alternate" hreflang="pt-BR" href="https://rainbowkit.com/pt-BR/guides/rainbowkit-wagmi-v2"/><xhtml:link rel="alternate" hreflang="ru" href="https://rainbowkit.com/ru/guides/rainbowkit-wagmi-v2"/><xhtml:link rel="alternate" hreflang="th" href="https://rainbowkit.com/th/guides/rainbowkit-wagmi-v2"/><xhtml:link rel="alternate" hreflang="tr" href="https://rainbowkit.com/tr/guides/rainbowkit-wagmi-v2"/><xhtml:link rel="alternate" hreflang="ua" href="https://rainbowkit.com/ua/guides/rainbowkit-wagmi-v2"/><xhtml:link rel="alternate" hreflang="zh-CN" href="https://rainbowkit.com/zh-CN/guides/rainbowkit-wagmi-v2"/></url>
<url><loc>https://rainbowkit.com/guides/walletconnect-v2</loc><changefreq>daily</changefreq><priority>0.7</priority><xhtml:link rel="alternate" hreflang="en-US" href="https://rainbowkit.com/en-US/guides/walletconnect-v2"/><xhtml:link rel="alternate" hreflang="ar" href="https://rainbowkit.com/ar/guides/walletconnect-v2"/><xhtml:link rel="alternate" hreflang="es-419" href="https://rainbowkit.com/es-419/guides/walletconnect-v2"/><xhtml:link rel="alternate" hreflang="fr" href="https://rainbowkit.com/fr/guides/walletconnect-v2"/><xhtml:link rel="alternate" hreflang="hi" href="https://rainbowkit.com/hi/guides/walletconnect-v2"/><xhtml:link rel="alternate" hreflang="id" href="https://rainbowkit.com/id/guides/walletconnect-v2"/><xhtml:link rel="alternate" hreflang="ja" href="https://rainbowkit.com/ja/guides/walletconnect-v2"/><xhtml:link rel="alternate" hreflang="ko" href="https://rainbowkit.com/ko/guides/walletconnect-v2"/><xhtml:link rel="alternate" hreflang="pt-BR" href="https://rainbowkit.com/pt-BR/guides/walletconnect-v2"/><xhtml:link rel="alternate" hreflang="ru" href="https://rainbowkit.com/ru/guides/walletconnect-v2"/><xhtml:link rel="alternate" hreflang="th" href="https://rainbowkit.com/th/guides/walletconnect-v2"/><xhtml:link rel="alternate" hreflang="tr" href="https://rainbowkit.com/tr/guides/walletconnect-v2"/><xhtml:link rel="alternate" hreflang="ua" href="https://rainbowkit.com/ua/guides/walletconnect-v2"/><xhtml:link rel="alternate" hreflang="zh-CN" href="https://rainbowkit.com/zh-CN/guides/walletconnect-v2"/></url>
</urlset>
Binary file added site/public/social/guide-rainbowkit-v2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit d2ed284

Please sign in to comment.