IDKit
JS Reference
Here you will find information about all the configuration options and parameters that IDKit supports.
Parameters
The following parameters can be passed as props to the IDKitWidget
component.
Required Parameters
- Name
app_id
- Type
- string
- Description
Unique identifier for the app verifying the action. This should be the action ID obtained from the Developer Portal.
- Name
action
- Type
- string
- Description
Identifier for the action the user is performing. Should be left blank for Sign in with Worldcoin.
- Name
onSuccess
- Type
- function
- Description
Function to trigger when verification is successful. Should receive a single parameter of type
ISuccessResult
which contains the proof details.
Optional Parameters
- Name
handleVerify
- Type
- function
- Description
Called after the proof is returned from the World App, but before showing the success screen. Throwing in this screen will show the user a custom error. Used to perform additional validation when needed.
- Name
enableTelemetry
- Type
- boolean
- Description
Whether opt-in telemetry is enabled. Very few events are sent, with no PII to help improve the project.
- Name
theme
- Type
- "light" | "dark"
- Description
The theme to apply to the widget's UI.
- Name
signal
- Type
- string
- Description
For use when validating proofs on-chain. Read more on the On-chain section.
- Name
action_description
- Type
- string
- Description
The description of the specific action (shown to users in World App). Only recommended for actions created on-the-fly.
- Name
credential_types
- Type
- string[]
- Description
An array of credential types to allow for verification. Will accept any combination of
orb
&phone
. Defaults toorb
. TypeScript apps can use theCredentialType
enum.
Components
IDKitWidget
The IDKitWidget
component is the main component that renders the World ID widget. It should be mounted in your React app and passed the relevant parameters. Accepts a function as a child that receives a open
function to open the widget.
SignInWithWorldID
The SignInWithWorldID
component is a wrapper around the IDKitWidget
component that renders the World ID widget with the correct parameters for Sign in with Worldcoin.
SignInButton
The SignInButton
component is a styled and animated button, for use with Sign in with Worldcoin. It is the default when using the SignInWithWorldID
component, but also exported separately for use with custom components.
Hooks
useIDKit
The useIDKit
hook allows you to programmatically open the IDKit widget without mounting any buttons on screen. Note that you still need to mount the component for this to work.
import { useIDKit } from '@worldcoin/idkit'
const { open, setOpen } = useIDKit()
useEffect(() => {
setOpen(true)
}, [])
return (
<div>
<IDKitWidget app_id="..." action="..." />
</div>
)
Methods
.init()
The .init()
method is the main initialization method used for vanilla JS apps. It should be called to start up IDKit and configure the widget.
.init(parameters) => void
Example:
idkit.init({
action: 'my_action',
app_id: 'app_lshSNnaJfdt6Sohu6YAA',
})
.open()
The .open()
method is used to open the widget. It should be called after the .init()
method.
Example:
idkit.open()
Response
Upon successful completion of the World ID flow, you will receive a response object. This response object of type ISuccessResult
has the following attributes. Normally, you will forward these parameters to your backend or smart contract for verification.
- Name
merkle_root
- Type
- string
- Description
This is the hash pointer to the root of the Merkle tree that proves membership of the user's identity in the list of identities verified by the Orb. ABI encoded.
- Name
nullifier_hash
- Type
- string
- Description
Essentially the user's unique identifier for your app (and specific action if using Anonymous actions). ABI encoded.
- Name
proof
- Type
- string
- Description
The Zero-knowledge proof of the verification. ABI encoded.
- Name
credential_type
- Type
- "orb" | "phone"
- Description
Either
orb
orphone
.