Your frontend
Install and set up the Block-Auth widget in your React, Vue or Angular app, with no backend.
Your environment variables
Your apiKey is public and is all your frontend needs. Here it is with your data:
This is your frontend’s .env, at the root of your project.
VITE_BLOCKAUTH_API_KEY=your_api_keyReplace your_api_key with your API Key, or fill in your data in the SDK Quickstart and it is filled in for you.
Install the widget
Run it in your project folder, the one that has the package.json of your React, Vue or Angular app:
npm install @block-auth.io/react
Check that the package shows up in that package.json. If npm created a new package.json, you were in another folder: delete it along with its node_modules and run the install again in your project folder.
Angular: the widget brings wallet libraries with CommonJS modules and optional dependencies the Angular builder can't resolve. Add them to the build options in angular.json, or the build warns and fails. Also raise the initial budget of the production build: the wallets add about 1 MB and the default limit of new Angular projects (1 MB) stops ng build. If your angular.json already has budgets, change only the initial one. Select the Angular tab to see the configuration.
Configure the widget
Add it once, in the file where your app starts: src/main.jsx in React with Vite (src/index.js with CRA), src/main.ts (or src/main.js) in Vue and app.config.ts in Angular. authEndpoint: false is what tells the widget your app has no backend. Your app doesn't change: in React you wrap it as is, and in Vue you add the .use() to the chain you already have, before .mount().
import { createRoot } from 'react-dom/client'
Copyimport { BlockAuthProvider } from '@block-auth.io/react'
import { App } from './App'
Copyconst config = {
apiKey: import.meta.env.VITE_BLOCKAUTH_API_KEY,
authEndpoint: false,
locale: 'en',
}
createRoot(document.getElementById('root')).render(
Copy <BlockAuthProvider config={config}>
<App />
Copy </BlockAuthProvider>,
)
Never put the apiSecret in your app, not even in an environment variable
like VITE_… or NEXT_PUBLIC_…: the bundler copies it into the JavaScript
every visitor downloads. Without a backend you don't need it.
Config options
apiKey(string, required): your app's API key. It's public: it only says which app is calling.authEndpoint(false):falsefor an app without a backend. The widget then signs the user in by itself and keeps the session in the browser tab.locale(string): language of the widget,"en"or"es". By default, the browser's language.onSessionEnded(function): called when the session ends outside your page, for example after the user signed out from Block-Auth Identity or the extension. The widget checks it when the tab gets focus and every 5 minutes, and already shows the user as signed out: use it to leave pages for signed-in users.wsUrl(string): the Block-Auth server the widget talks to. By default production (wss://wss.block-auth.io): change it only if Block-Auth gives you another environment to test against.
The login itself happens on the Block-Auth login page (auth.block-auth.io), so you don't configure Google, Microsoft, wallets or WalletConnect in your app.
Add the login button
Place FlowBlockAuth where you want the sign-in button. After the login it turns into the profile menu, with its own sign out, and on reload it restores the session kept in the browser tab. A new tab or window asks to sign in again.
Copyimport { FlowBlockAuth } from '@block-auth.io/react'
export function Header() {
return (
<header>
Copy <FlowBlockAuth
onSuccess={(address) => console.log('Signed in as', address)}
onError={() => alert('Sign-in failed, try again.')}
onLogout={() => window.location.assign('/')}
/>
</header>
)
}
The button opens the login in a popup. If the browser blocks the popup, the widget opens the login in the same tab: Block-Auth sends the user back to the root of your app (/), which must load your frontend with the widget config, and the widget finishes the login on the page where it started. More in Login with a redirect. To change how the button looks, see Customize the widget.
Show who is signed in
The widget already shows the profile menu. To use the user in your own components, read it with useBlockAuthUser() in React and Vue, or with the BlockAuthService signals in Angular. user has the address, the did and the roles, or is null if nobody is signed in:
To show or hide parts of your UI by role, see Roles. It only changes what the page shows: don't use it to protect data.
Does your server send a Content-Security-Policy? You won’t notice in development, but in production it blocks the widget: unstyled button, broken logo and failed login. When you deploy, allow it as explained in Go live.
Checklist
Go over these before trying it. They adapt to your framework and your choices:
React · Vite
- The package is installed
@block-auth.io/reactshows up in your frontendpackage.json, not in a new one created elsewhere. BlockAuthProviderwraps your whole app insrc/main.jsx.- Your apiKey comes from
VITE_BLOCKAUTH_API_KEYin.env, read withimport.meta.env.VITE_BLOCKAUTH_API_KEY. If a change doesn’t apply, restartnpm run dev. - The widget config has
authEndpoint: falseso the widget signs the user in by itself, without backend routes. - The button is where you want it
<FlowBlockAuth />, for example in your header. - The widget handles the logout after the login the button becomes the profile menu, with its own sign out.
- The
apiSecretisn’t anywhere in your app without a backend you don’t use it, so never put it in the frontend.
Next: Try it.

