RainbowKit
Integrate social logins within RainbowKit through Particle Auth.
Leveraging Particle Auth within RainbowKit
One of the most widely used methods of implementing Particle Auth is through RainbowKit. By leveraging RainbowKit as the underlying connection mechanism within your application, you can facilitate both Web2-based social logins with Particle Auth (through a custom wagmi connector powered by @particle-network/auth-core-modal
) or Web3-native wallet connections. This unification of social logins and external wallet connections is also possible through Particle Connect, although if you’d like to use RainbowKit, including Particle Auth within the list of connection options is simple.
Implementing particleWagmiWallet
If you’re already using RainbowKit within your application, you can set up a custom wagmi connector, particleWagmiWallet
alongside its respective derivatives, including particleGoogleWallet
, particleTwitterWallet
, and any other social login implementations that you’d like to include within your RainbowKit instance (through wallets
within RainbowKit’s connectorsForWallets
).
To build custom Particle Auth connectors of this nature, follow the walkthrough below.
Walkthrough
-
First, set up the
particleWagmiWallet
connector. You’ll first need to create an additional file within your project to hold the custom connector, such asparticleWagmiWallet.ts
. This file should include the below snippet:particleWagmiWallet.ts -
Initializing connector instances (such as
particleGoogleWallet
). With theparticleWagmiWallet
connector set up, you’ll need to establish a number of configured (derivative) connector instances to include specific social logins within your RainbowKit instance (these should be placed in thewallets
array while configuringconnectorsForWallets
). An example of this is included below:
-
Wrapping your
ConnectButton
instance with a social login patch. When using Particle Auth Core with RainbowKit, you’ll need to add a short snippet that fixes a few common issues that may arise when using social logins with wagmi. In our demo, we place this within theApp.tsx
file, which is then rendered in place ofConnectButton
directly. Below is the snippet in question:
Demo repository available
To dive further into this process and view a practical example of implementation, take a look at the following demo repository:
1. Next.js example.
2. (create-react-app example coming soon)
Common issues
The following issues might be encountered in this process:
- Minification for Vercel deployments, generally seen as
Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'sqrt')
.- Occasionally, Vercel deployments are known to throw errors relating to the minifier you’re using, crashing the application upon startup. This is due to the usage of
swcMinify
within yournext.config.js
file. You’ll need to switchswcMinify
fromtrue
tofalse
, thus using Terser as the minifier rather than SWC.
- Occasionally, Vercel deployments are known to throw errors relating to the minifier you’re using, crashing the application upon startup. This is due to the usage of
📹 A full walkthrough video on leveraging Particle Auth within RainbowKit is available.
For an extended explanation and tutorial regarding the integration of Particle Auth within RainbowKit, we’ve created a video and GitHub template repository.
Was this page helpful?