React, Vue or Angular
Follow this guide if your frontend is a React, Vue or Angular app. At the end your users sign in with Block-Auth and your backend has a verified session for them.
What you'll build
You need two pieces, and this guide covers both:
- In your frontend: the Block-Auth widget (
@block-auth.io/react,/vueor/angular). It shows the sign-in button and opens the login. - In your backend: three routes that redeem the login code with your API secret. Your backend can be in any language: the examples are in Node.js, PHP, Python and .NET.
The browser never decides who the user is: the widget only passes a one-time code to your backend, and your backend gets the user from Block-Auth.
- 1Your frontend → Block-AuthLogin in a popup (PKCE)
- 2Block-Auth → Your frontendOne-time code
- 3Your frontend → Your backendPOST /code
- 4Your backend → Block-AuthPOST /api/auth/token
- 5Block-Auth → Your backend{ address, roles }
- 6Your backend → Your frontendhttpOnly session cookie
- 7Your frontend → Your backendGET /me
- 8Your backend → Your frontend{ address, roles }
Your frontend
Block-Auth widget
Your backend
Your code
Block-Auth
Hosted by Block-Auth
- 1Login in a popup (PKCE)
- 2One-time code
- 3POST /code
- 4POST /api/auth/token
- 5{ address, roles }
- 6httpOnly session cookie
- 7GET /me
- 8{ address, roles }
Prepare your app
- In the Dashboard, create your application following the Integration Quickstart. As the domain, enter the host where your frontend runs (for example
your-app.com). - Pick the keys based on where your app is going to run. Each environment has its own in Applications » Integration details, and they don't mix:
| Where your app runs | Which keys to use | Where you put them |
|---|---|---|
Your computer (localhost) | The Development ones. They work right away. | The .env on your computer |
| Your live server | The Production ones. They work once you validate your domain. | Your server's environment variables |
- Fill in your data once in the SDK Quickstart: from then on, each guide gives you the files and code already adapted to your app.

