Integrate social logins within Web3-Onboard through Particle Auth.
@web3-onboard/particle-network
, allowing social logins to be seamlessly included within an instance of Web3-Onboard, as is shown in the embedded demo below.
@web3-onboard/particle-network
ParticleNetwork
from @particle-network/auth
to be configured and defined within Onboard
from @web3-onboard/core
.
Therefore, implementation of Particle Auth is straightforward, following the same configuration and initialization process as @particle-network/auth
. The following steps facilitate this process:
particleModule
from @web3-onboard/particle-network
. After installing @web3-onboard/particle-network
and importing particleModule
, you’ll need to define an instance using an object containing the following properties.
projectId
, clientKey
, and appId
. These are required values representing a project and application made through the Particle dashboard.wallet
can be defined, which contains:
displayWalletEntry
, a Boolean determining whether or not the embedded wallet modal is shown upon login (true
by default).defaultWalletEntryPosition
, a string defining the position in which the embedded wallet modal will initially appear if displayWalletEntry
is true
.preferredAuthType
can be defined to shortcut your instance of Particle Auth to a specific social login mechanism. This parameter contains:
type
, the specific social login type you’d like to be used. This should be one of the following:
'email'
'phone'
'facebook'
'google'
'apple'
'twitter'
'discord'
'github'
'twitch'
'microsoft'
'linkedin'
'jwt'
AuthType.google
, AuthType.email
, etc., which can be imported from @particle-network/auth-core
.setAsDisplay
, a Boolean determining if the social login mechanism chosen within type
will be represented within the Web3-Onboard interface (for example, changing the wallet option to “Google” rather than the default value of “Particle Network”).particleModule
may look like:Onboard
. With an instance of particleModule
prepared, you’re ready to configure Onboard
from @web3-onboard/core
. Onboard
takes the following parameters.
wallets
, an array of initialized wallet modules. Your instance of particleModule
should go here. For a complete list of compatible wallet modules, head over to the Web3-Onboard documentation.chains
, an array of chain objects representing the blockchains you intend to use within your application. Each of these objects should contain:
id
, (chain ID).token
(ticker).label
(name).rpcUrl
Onboard
) may look like the following snippet.{your Onboard instance}.connectWallet()
. This will return an object containing an associated EIP-1193 provider, which can then be used for configuration within a library such as Ethers, Web3.js, viem, etc. An example of this has been included below:
Additional resources available
Web3-Onboard has native documentation available for @web3-onboard/particle-network
, which includes additional code snippets and implementation details.