Quickstart: Integrating Particle Connect into Your Web Application
Integrating Particle Connect into your web application can be done in under five minutes.
This guide provides a concise overview of how to install, configure, and enable social logins in a Next.js application using create @particle-network/connectkit
as your starting point.
For a detailed explanation of each feature and more advanced configurations, refer to the Particle Connect SDK reference.
Boilerplate: Initializing Particle Connect
The easiest way to get started with Particle Connect is through its built-in starter/boilerplate; this includes the core file setup and code structure needed to configure Particle Connect.
To initialize this boilerplate, copy and execute one of the following commands.
After running one of the aforementioned commands, the CLI will guide you through a setup process; it will prompt you to enter a project name, choose your preferred framework (Next.js or React), and select additional options.
Configuring Particle Connect
With a starter project initialized, you’re ready to configure Particle Connect through its core component, ConnectKitProvider
.
Although before diving in too deep here, you’ll need some keys from the Particle dashboard.
Particle Connect requires three key values from the dashboard to be initiated: projectId
, clientKey
, and appId
.
To retrieve these values for configuration within your application, follow these steps:
After obtaining your projectId
, clientKey
, and appId
, you’ll need to use these to configure the aforementioned ConnectKitProvider
component from @particle-network/connectkit
.
The boilerplate already includes the basic variable setup —just add your API keys to the .env.sample
file and rename it to .env
.
At this point, you’re ready to move onto either running and testing the application or beginning development through app/page.tsx
.
Although, below we’ll continue and go over some of the granular controls given to you through ConnectKitProvider
.
Configuring ConnectKitProvider
When working with ConnectKitProvider
, it’s recommended to use a dedicated Connectkit.tsx
file in the src
directory where you can configure and export the component. Then, you’ll use this export to wrap your main App component (the location of your Particle Connect implementation through ConnectButton
).
Here’s how you can configure ConnectKitProvider
:
Required Configurations:
projectId
,clientKey
, andappId
— Get these from the Particle dashboard, as covered prior.chains
— Specify the supported chains for your dApp (this is an array of Viem-originating chain objects imported from@particle-network/connectkit/chains
).walletConnectors
— Define the wallets you want to support.
Optional Configurations:
theme
andlanguage
for basic customization of the connection modal UI.- Additional appearance customizations.
Connectkit.tsx
file located in the src
directory.Below is an example of a configured instance of ConnectKitProvider
. For more details around each available property, head over to the Particle Connect Web SDK reference.
Wrap your application with ConnectKitProvider
Wrap your primary application component (wherever you place and use ConnectButton
alongside the various hooks from Particle Connect) with the ParticleConnectKit
component (exported from ConnectKitProvider
).
Here’s an example of what this looks like for a layout.tsx
file:
layout.tsx
file located in the app
directory.Facilitating logins and chain interactions
With Particle Connect now configured, you can proceed to enable social logins within your application through the aforementioned ConnectButton
component.
Additionally, for driving application-level interaction (after initial onboarding), @particle-network/connectkit
provides a variety of hooks. You can explore all available hooks in the Particle Connect SDK documentation.
The boilerplate application includes a basic example featuring only a Connect button (ConnectButton
).
After logging in (connecting), users can access the embedded wallet modal provided by Particle Connect via the button in the bottom right corner, unless customized through the wallet
configuration within ConnectKitProvider
.
To explore additional features like fetching and displaying user information, balances, on-ramp services, and sending transactions using either the native Particle Provider (Viem-based WalletClient) or ethers.js through an EIP-1193 provider, paste the following code into app/page.tsx
.
A Next.js demo repository containing the above code can be found here.
Was this page helpful?