ic-reactor 4 is out: typed calls to Internet Computer canisters from TypeScript and React, built on TanStack Query. Generate a module from a canister’s .did file, then call it:
import { createClient } from "@ic-reactor/core"
import { actor, type Actor } from "./generated/icrc1" // from icrc1.did
const client = createClient({ network: "ic", identity: "anonymous" })
const ledger = client.canister<Actor>(actor, {
id: "ryjl3-tyaaa-aaaaa-aaaba-cai", // the ICP ledger
})
console.log(await ledger.icrc1_fee()) // 10000n
Reads cached per caller, and cleared on sign-out
One error type that says whether a failed call may have run
Internet Identity 2.0 sign-in, including one-click Google, Apple and Microsoft
React hooks, a Vite plugin, a test client and exact token units
The module comes from Meant. It also compiles the .did into a canonical JSON contract, with its own identity and room for extensions, so tools can build on the exact interface safely, without parsing Candid themselves. Much more is coming on top of it, like profiles that say what each value means and what each call does, for AI agent tools and consent messages. More on that soon in its own thread…
ic-reactor 4.3.0 is out, ready for Internet Identity’s revocable sessions.
import { createClient } from "@ic-reactor/core"
import { ReactorProvider, useAuth } from "@ic-reactor/react"
import { AuthClient } from "@icp-sdk/auth/client"
export const App = () => (
<ReactorProvider
client={() => createClient({ network: "ic", auth: (network) => new AuthClient(network) })}
>
<Account />
</ReactorProvider>
)
// Re-renders when another tab signs in or out, or the session ends
function Account() {
const { status, principal, signIn, signOut } = useAuth()
if (status === "signed-in") {
return <button onClick={() => signOut().catch(console.error)}>Sign out {principal}</button>
}
return (
<>
{status === "expired" && <p>Your session ended.</p>}
<button onClick={() => signIn().catch(console.error)}>Sign in</button>
</>
)
}
When a session ends (a sign-out in any tab, an idle timeout, or a device signed out in II’s settings), the client drops that user’s agent and cached reads, and useAuth() re-renders with the new status. A call that needed the ended session is refused before it is sent, so it’s safe to retry after signing in.
The Vite plugin now requires a Vite with the CVE-2025-24010 fix (4.5.6, 5.4.12, 6.0.9, or 7 and later).
client.time() refuses an IC time more than five minutes older than one it has already read.