Integrate Rainbow App
RainbowKit works with Wagmi wallet connector that allows Web3 app users to easily switch between multiple wallets within a single application. For Web3 apps using RainbowKit, the Arcana Auth SDK offers a custom Wagmi connector that can be used to enable the Arcana wallet in the app's context.
In this guide, you will learn how to integrate Web3 RainbowKit apps with the Arcana Auth SDK.
Prerequisites
-
Register Web3 Application: Log into the Arcana Developer Dashboard https://dashboard.arcana.network to register and configure the app before they can use the Arcana Auth SDK and enable the Arcana wallet for authenticated app users.
-
Set up Authentication Providers: Click on the Social Auth tab in the Arcana Developer Dashboard. Configure and select one or more supported authentication providers for onboarding the app users.
- Discord
- GitHub
- Twitch
Configure Authentication Providers
You may be required to configure additional provider details for different authentication providers. In the case of Google, the developer must use Google Developer Console to set up the app and generate a Google assigned client ID for Google OAuth. This Google ClientID will be configured in the Arcana Developer Dashboard Social Auth settings before integrating the app.
For details, see how to configure authentication providers.
-
Save the Client ID assigned to the app and displayed in the Arcana Developer Dashboard. It is required later during integrating with the Arcana Auth SDK.
Steps
Integrating Web3 RainbowKit apps with the Arcana Auth SDK is simple!
Follow these three steps:
Step 1: Install Arcana Auth SDK packages
npm
npm install --save @arcana/auth-wagmi @arcana/auth
yarn
yarn add @arcana/auth-wagmi @arcana/auth
Step 2: Configure RainbowKit Connector
Import auth
package and create AuthProvider
by specifying the unique Client ID value assigned to the app after registering and configuring it using the Arcana Developer Dashboard. Then import auth-wagmi
package and create an ArcanaConnector
.
Set up ArcanaRainbowConnector
using the newly created ArcanaConnector
. Initialize the connectorsForWallets
in the RainbowKit with the ArcanaRainbowConnector
and export the connectors
to be used later in the _app.js
file:
import { AuthProvider } from "@arcana/auth";
import { ArcanaConnector } from "@arcana/auth-wagmi";
import { polygon, polygonMumbai } from "wagmi/chains";
import { configureChains, createClient, Chain } from "wagmi";
import { publicProvider } from "wagmi/providers/public";
const auth = new AuthProvider(`${arcana_client_id}`) // Singleton
export const connector = (chains: Chain[]) => {
return new ArcanaConnector({
chains,
options: {
auth: auth,
},
});
};
...
Use the connectors
configured with ArcanaRainbowConnector
in the _app.js
file for creating the Wagmi client using the createClient
function:
import "../styles/globals.css";
import "@rainbow-me/rainbowkit/styles.css";
import { configureChains, createClient, WagmiConfig } from "wagmi";
import { polygon, mainnet } from "wagmi/chains";
import { publicProvider } from "wagmi/providers/public";
import { RainbowKitProvider } from "@rainbow-me/rainbowkit";
import { connectors } from "../utils/wallet";
const { chains, provider } = configureChains(
[mainnet, polygon],
[publicProvider()]
);
const wagmiClient = createClient({
autoConnect: true,
connectors: connectors(chains),
provider,
});
Wagmi createClient
For more details on the createClient
function of the Wagmi package, see wagmi Getting Started Guide. Also, refer to RainbowKit documentation.
Step 3: RainbowKit Context Provider
Finally, pass the wagmiClient
created earlier as a parameter to the WagmiConfig
component in the _app.js
file.
// Pass wagmi client configured with ArcanaRainbowKitConnector to the RainbowKit Context Provider
export default function App({ Component, pageProps }) {
return (
<WagmiConfig client={wagmiClient}>
<RainbowKitProvider chains={chains}>
<Component {...pageProps} />
</RainbowKitProvider>
</WagmiConfig>
);
}
That is all!
The Web3 app using RainbowKit is successfully integrated with the Arcana Auth SDK.
Example: Sample RainbowKit App
See sample RainbowKit app for details.
What's Next?
After integrating with a Web3 RainbowKit app with the Arcana Auth SDK, the developers can add code to onboard users. There are two ways to onboard users:
- Use built-in plug-and-play login UI with a single function call that displays all the configured authentication providers
- Use custom login UI to onboard users and wire it to the Arcana Auth SDK functions for calling the configured authentication providers.
See for details.
Arcana wallet can also be used in applications that integrate with Wagmi. For details, see how to enable Arcana wallet in apps using Wagmi.