@peltier/react-core
v0.2.0
Published
Peltier shared React bindings — PeltierProvider and the headless flow hooks. Platform-neutral (no DOM, no react-native imports); consumed by @peltier/react and @peltier/react-native.
Readme
@peltier/react-core
Shared React bindings for the Peltier SDK — PeltierProvider and the headless
flow-engine hooks, consumed by
@peltier/react (web) and
@peltier/react-native.
Platform-neutral: no DOM and no react-native imports.
Most apps should not install this directly. Use
@peltier/react(web) or@peltier/react-native— both re-export everything here. Reach for@peltier/react-coreonly to share hook-driven payment code across web and RN from one dependency.
npm install @peltier/react-core viemWhat's exported
PeltierProvider/usePeltier— configuration context (apiUrl,publishableKey, mode resolution). The publishable key is required: the provider throws at mount without a validpk_test_…/pk_live_…(a secretsk_key is rejected outright), and every widget session is tagged with the owning merchant. The headless engines below stay key-optional.- Headless flow engines — each widget in the UI packages is a thin skin over
one of these:
useDepositSession— register a deposit, watch it settleuseRequestSession— create + track a payment requestuseSendFromWallet— EIP-1193 send with fail-closed calldata verificationuseStealthRequest— stealth-address request flow
- Status + errors —
SessionView(a normalized view of session state),toPeltierError, and the typedPeltierError(code+retryable). Engines also exposeconnectionState: 'connecting' | 'live' | 'reconnecting' | 'polling'.
Example — headless deposit
import { useDepositSession } from '@peltier/react-core'
import { DEFAULT_IMPLEMENTATION_ADDRESS } from '@peltier/core'
function Deposit() {
const { burnerAddress, status, error, connectionState, retryCommit, reset } =
useDepositSession({
apiUrl: 'https://api.peltier.dev',
implementationAddress: DEFAULT_IMPLEMENTATION_ADDRESS,
destinationAddress: '0xYourAddress',
destinationChainId: 8453,
onComplete: (id) => console.log('Done:', id),
})
// burnerAddress → show/QR-encode; status/error/connectionState → render as you like
return <YourOwnUi address={burnerAddress} status={status} />
}Related packages
| Package | For |
|---|---|
| @peltier/core | React-free protocol core |
| @peltier/react | web widgets (<DepositWidget>, checkout components, styles) |
| @peltier/react-native | RN widgets (QR/clipboard injected via props) |
| @peltier/node | backend: 402 gate, webhooks, subscriptions |
Docs
Full documentation lives at peltier.dev/docs.
License
MIT
