Open SuperRare commerce in a hosted window.
SuperRare Connect is a browser SDK for hosted buy, sell, bid, mint, settle, offer, transfer, checkout, authentication, and intent-status flows. Studio remains the host; Connect remains responsible for commerce and wallet execution.
Install and create a client
npm install --save-exact @rareprotocol/connect@0.11.0
import { createSuperRareClient } from "@rareprotocol/connect";
const superrare = createSuperRareClient({
onIntentSettled: (intent) => refreshOrder(intent),
});The package ships ESM, CommonJS, and a browser-global (SuperRareConnect) build. Options include apiUrl and connectUrl for test environments, popup sizing, onIntentSettled, a custom fetch, and sessionStorage: false for apps that do not want SDK-managed browser storage.
Hosted windows
Every flow opens in a small centered window, so your page keeps its state while the user signs in or pays. Call the action directly from a click handler: the window opens synchronously inside the user gesture. If the browser blocks it, the call rejects with ConnectPopupBlockedError before any intent is created. onIntentSettled reports the final status when the flow finishes, or the latest known state if the user closes the window early, so check intent.status before acting on it.
Commerce actions
await superrare.actions.buy({
target: {
kind: "erc721-direct-listing",
chainId: 1,
contract: "0x…",
tokenId: "1",
},
expected: { currency: "ETH", price: "1000000000000000" }, // wei
returnPath: "/connect/return",
});Prices and amounts are raw base-unit strings: wei for ETH and 6 decimals for USDC. Every action except transfer accepts payment: { method: "wallet" } to keep the checkout wallet-only. Use it when a custom contract keys anything on the receiving wallet, because card settlement delivers through a SuperRare buy proxy.
Transfers for off-chain goods
await superrare.actions.transfer({
chainId: 1,
to: "0x…", // your wallet
currency: "USDC",
amount: "25000000", // 25 USDC
beforeOpen: async ({ intentId }) => {
await linkOrder("order_123", intentId);
},
});Transfers are wallet-only. beforeOpen runs after the intent is created and before the window shows the payment; if it throws, the window closes and the call rejects, so the user never sees a payment your backend has not recorded.
GET /v1/connect/intents/:intentId itself and credits each intent once, only when status is completed, actionType is transfer, and the terms chainId, recipient, amount, and currency match the order.Intent status
import { resolveConnectIntentOutcome } from "@rareprotocol/connect";
const intent = await superrare.intents.get({ intentId });
const outcome = resolveConnectIntentOutcome(intent);
switch (outcome.kind) {
case "pending": showPending(); break;
case "completed": showSuccess(); break;
case "failed": showFailure(outcome); break;
}Authentication and user data
Connect authentication is optional for checkout, buy, bid, mint, settle, transfer, and status flows. It does not replace Studio login.
Test on Sepolia
const superrare = createSuperRareClient({
apiUrl: "https://rare-api-dev-mainnet.superrare.co",
connectUrl: "https://connect-dev-mainnet.superrare.co",
});Production executes Ethereum mainnet only. The dev pair above executes both mainnet and Sepolia: pass chainId: 11155111 on the action target and use a wallet funded with Sepolia ETH. Switch back to the defaults for production.
Errors and production readiness
Handle ConnectPopupBlockedError, ConnectActionValidationError, ConnectReturnPathError, ConnectSessionRequiredError, and SuperRareConnectApiError as distinct states. The SDK intentionally rejects arbitrary calldata, contract instructions, private keys, API secrets, and wallet-provider objects.
- Exercise the configured test environment
- Render pending, completed, failed, and interrupted
- Verify identifiers and chain
- Keep Studio and Connect sessions separate
- Recover from a closed hosted window
- Do not infer success from the window closing
- Confirm card settlement before fulfillment
- Credit transfers only from your backend

