@bondify/react package gives you idiomatic React primitives for Telegram authentication — a context provider, a drop-in button component, and a hook that exposes auth state and actions anywhere in your component tree. You wrap your app in <PulseProvider>, drop in <PulseButton> where you want the login UI, and access the resulting user session via usePulse().
Installation
- npm
- yarn
- pnpm
<PulseProvider>
PulseProvider is the context provider that supplies your Bondify project configuration to every component and hook below it in the tree. Place it near the root of your app — or around just the pages that require authentication.
Props
Your Bondify project ID from the dashboard. All SDK calls inside this provider use this ID to identify your project.
Every
<PulseButton> and every usePulse() call must be rendered inside a <PulseProvider>. Rendering either outside the provider will throw a runtime error.<PulseButton>
PulseButton is a pre-styled, self-contained authentication button. It handles the full auth flow internally — loading state, Telegram deeplink, status confirmation, and callbacks — so you only need to handle the result.
Props
Called with the resolved
User object when authentication succeeds. The user object contains:telegramId— the user’s Telegram IDname— the user’s display nameusername— the user’s @handle, ornullif not setproof— the signed session proof (verify this on your server)channel— the authentication channel, e.g."telegram"
Called with a
TGAuthError on failure. Inspect err.code — possible values are CANCELLED, EXPIRED, and TIMEOUT.Custom label for the button. Defaults to
"Sign in with Telegram".Visual theme for the button. Accepts
"light" (white background, blue border) or "dark" (dark navy background). Defaults to the standard Telegram blue.usePulse() hook
The usePulse() hook gives you access to the current auth state and the signIn / signOut actions from any component inside <PulseProvider>. Use it to build custom auth UI, protect routes, or personalise content.
Return value
The authenticated user object, or
null when no user is logged in. When present, the object has the following shape:true when a user is currently authenticated, false otherwise. Use this for conditional rendering of protected content.Triggers the Telegram authentication flow programmatically — identical to calling
client.signIn() on the Web SDK. Call this only from a user gesture (e.g. a button’s onClick).Clears the authenticated user from context state. You are responsible for invalidating any session cookie or JWT on your server in parallel.
Full integration example
The following example shows how all three pieces —PulseProvider, PulseButton, and usePulse — work together in a Next.js app.
Wrap your app with PulseProvider
In
pages/_app.tsx (Pages Router) or app/layout.tsx (App Router), add the provider:Verify the proof on your server
In your API route (
/api/auth/verify), use @bondify/server to validate the proof before issuing a session: