Loading...
Loading...
Core infrastructure providing backend connection configuration, storage client, and React app entry point.
npx skill4agent add caffeinelabs/skills extension-core-infrastructure"@icp-sdk/auth": "^7.1.0"
"@icp-sdk/core": "^5.3.0"@caffeineai/core-infrastructureInternetIdentityProviderQueryClientProviderimport { InternetIdentityProvider } from "@caffeineai/core-infrastructure";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import ReactDOM from "react-dom/client";
import App from "./App";
const queryClient = new QueryClient();
ReactDOM.createRoot(document.getElementById("root")!).render(
<QueryClientProvider client={queryClient}>
<InternetIdentityProvider>
<App />
</InternetIdentityProvider>
</QueryClientProvider>,
);useInternetIdentity()| Field | Type | Description |
|---|---|---|
| | The user's identity (available after login or session restore) |
| | Opens the II popup. Fire-and-forget — do not |
| | Logs out and clears stored identity. Fire-and-forget. |
| | |
| | |
| | |
| | |
| | |
| | The error object when |
| Scenario | | |
|---|---|---|
| Page load, no stored session | | |
| Restoring stored session | | |
| Stored session restored after reload | | |
| Interactive login in progress | | |
| Interactive login just completed | | |
| Login popup failed / cancelled | | |
isLoginSuccesstrueisAuthenticatedisAuthenticatedconst { isAuthenticated } = useInternetIdentity();
{isAuthenticated ? <AuthenticatedApp /> : <LoginScreen />}const { login, isInitializing, isLoggingIn } = useInternetIdentity();
<button onClick={() => login()} disabled={isInitializing || isLoggingIn}>
Sign in
</button>login()clear()isLoggingInisInitializinguseStateisPendinguseActor()import { useActor } from "@caffeineai/core-infrastructure";
import { createActor } from "declarations/backend";
function MyComponent() {
const { actor, isFetching } = useActor(createActor);
// actor is null while loading, then the typed backend actor
if (!actor || isFetching) return <Loading />;
// Call backend methods directly
const data = await actor.myBackendMethod();
}| Field | Type | Description |
|---|---|---|
| | The typed backend actor, or |
| | |