React Hooks
The @actioncodes/sdk/react
module provides convenient hooks for consuming Action Codes in React applications.
📥 useActionCode(code)
Resolves and decrypts metadata associated with an Action Code. Automatically fetches on mount and when code
changes.
const { action, intendedFor, loading, error, refetch } = useActionCode(code);
Returned Fields
Field | Description |
---|---|
action | Partial metadata like label, message, references |
intendedFor | Wallet that is authorized to use this code |
loading | Boolean loading state |
error | Error object if resolution fails |
refetch | Function to manually re-run the resolution |
🚀 useSubmitAction()
Submits an Action Code and tracks its live status. Useful for executing a transaction or triggering a one-time intent.
const { submit, status, loading, error, reset } = useSubmitAction();
Returned Fields
Field | Description |
---|---|
submit(code, fields) | Starts submission and status tracking |
status | Latest status string (e.g. 'pending', 'ready') |
loading | Boolean loading state |
error | Error object if the action fails |
reset() | Clears state for reuse |