Integrating the UI SDK into a non-React application
Integrating the UI SDK into a non-React application
This page guides you through the steps required to integrate the UI SDK into an application without the React library.
Check also the HTML/Javascript demo in the csprclick-examples repository to see the resulting application. In that repo you can find also examples or few other libraries/frameworks.
Get CSPR.click UI scripts from the CDN:
Before the closing head
tag, add a script
element to download the CSPR.click scripts:
Add a container for the CSPR.click navigation bar
In your main layout file, add a <div>
container for the CSPR.click navigation top bar. Set an id
, you'll need it later during CSPR.click initialization.
In the current version, it's important that your application is wrapped within a <div id="root">
element. This tells the modal components where is your main content. In a future version, you'll be able to change the id of this container.
Also, depending on the layout of your application and the grid system you're using, you'll need to add some CSS styles to the container to match the styles of the rest of the app.
Configure the initialization of the CSPR.click SDK
In a javascript file, add the initialization options for the CSPR.click SDK. Make sure this script loads before CSPR.click is downloaded.
The minimal configuration for the UI just defines the container for the navigation tob bar. We'll see other options later in this document.
Next, define Client SDK options:
Finally, in most of the cases your application will need to respond to respond to some events updating the state, initiating a user session, etc. For that purpose, add a listener for the csprclick:loaded
message and register your callback functions for the different events triggered by the CSPR.click library:
You can read more about events in the Handling events page.
Try it!
At this point, your application should show the CSPR.click top navigation bar and you can click on Sign in button to process with the connection of your favorite wallet.
Note in the console that the application is receiving the events when you connect, disconnect, etc.
Add options to the navigation bar
To finish this guide, let's add some of the prebuilt components. You can customize the navigation bar to fit the needs of your application. In the code example below we're adding a theme selector and a network selector as well as a couple of menu items to the account dropdown menu.
Last updated