React Component
Last updated
Was this helpful?
Last updated
Was this helpful?
The Login with DIMO React Component SDK provides developers with a set of pre-built, customizable building blocks for applications that integrate with DIMO. These components simplify the process of integrating our Accounts API and Transactions SDK in React applications.
clientId
*
String
redirectUri
*
String
apiKey
String
environment
String
Environment where your app is registered to. Defaults to production
if not indicated. Supports development
or production
at the moment.
options
Object
Additional options for the Login with DIMO Component. Currently supports forceEmail:true,
which requires users to opt into email sharing when logging in. If excluded, defaults to optional email sharing on login.
Depending on the component you're looking to surface, choose between the following inputs:
LoginWithDimo
& ShareVehiclesWithDimo
mode
*
String
One of the two available modes: popup
or redirect
.
onSuccess
*
Callback
Callback function called when the authData
is returned for popup
mode.
Example for authData
:
{ token: <access_token> }
For redirect
mode, the access_token
is in the redirect URI.
Example for redirect: https://your-site.com/redirect?token=<access_token>&email=<user_email>
onError
*
Callback
Callback function called when error occurs.
permissionTemplateId
String
utm
String
vehicles
[String]
Optional array of vehicle tokenId
's to target for the logged in user. If vehicles
is not provided, the flow will pull all available vehicles.
This also filters out any vehicle tokenId
that doesn't belong to the signed-in user.
vehicleMakes
[String]
Optional array of vehicle makes to filter for compatibility with your app. If vehicleMakes
is not provided, all available vehicles will be marked as compatible.
Example: [ 'Tesla', 'Audi', 'Lexus' ]
expirationDate
[String]
authenticatedLabel
[String]
Optional parameter to override default button label text for authenticated users.
unAuthenticatedLabel
[String]
Optional parameter to override default button label text for unauthenticated users.
For more information on these inputs, see: Core Functionalities
ExecuteAdvancedTransactionWithDimo
mode
*
String
One of the two available modes: popup
or redirect
.
onSuccess
*
Callback
Callback function called when data
is returned for popup
mode.
Example: data: { token: <access_token>; transactionHash: <tx_hash>; transactionReceipt: <tx_receipt>; }
onError
*
Callback
Callback function called when error occurs.
address
*
String
The 0x address of the smart contract being executed.
abi
*
Any
An array of JSON representing the ABI of the advanced functions of interest.
functionName
*
String
The name of the function being called.
args
*
[String]
The arguments being passed into the function call.
value
String
Optional number in wei of the native currency sent as a part of the transaction.
Congratulations for reaching this step, you're one huge step closer to launching an integration with DIMO!
If you've made it this far, you've successfully set up Login with DIMO. To access vehicle data after a user has shared access with you, we recommend implementing using the Data SDK on the backend. When a user authenticates via the Login component, their walletAddress
is returned - meaning you're ready to query the Identity API to obtain the Token IDs of the vehicles that were shared with you.
Take me to the Data SDK Docs →
DimoAuthProvider
is used to get the auth state value from the SDK, as well as to keep track of the user email, Global Account public address, and the User JWT.
Any components that require this value should be wrapped in the DimoAuthProvider
, as follows:
When permissionTemplateId
are provided:
Shows "No vehicles connected" with a Continue Button
Shows "All vehicles have been shared" with a Continue Button
Show list of all vehicles for permission sharing
When permissionTemplateId
are NOT provided. Since permissions are not requested, developers can couple this with the ShareVehiclesWithDimo
component post-login:
Skips permission sharing
Skips permission sharing
Skips permission sharing
This is a decoupled component that developers can use post-login, will trigger login if user isn't logged in:
Shows "No vehicles connected" with a Continue Button
Shows "All vehicles have been shared" with a Continue Button
Show list of all vehicles for permission sharing
This is a decouple component that developers can use post-login, will trigger login if user isn't logged in.
popup
The popup
mode surfaces a React button component that opens up a browser pop-up (new window) containing the Login with DIMO interface.
redirect
The redirect
mode surfaces a React button component that redirects the users to the Login with DIMO interface.
A valid client ID registered with your .
A valid redirect URI registered with your .
Optional API key of your . This is currently not in use and reserved for future applications.
Optional template ID of the template on IPFS. If undefined
, no permissions flow will be triggered for the end users.
For ShareVehiclesWithDimo
component, this is required as sharing requires permission templates.
Optional parameter for configuring UTMs. Useful for campaign tracking.
Example:
<LoginWithDimo utm="utm_campaign=dimo" />
will redirect to:
Optional parameter to explicitly specify an expiration date for permissions in the (YYYY-MM-DD).