---
title: "React, Vue or Angular: your frontend"
description: "Install and set up the Block-Auth widget in your React, Vue or Angular app."
url: "/sdk-integration-spa-frontend/"
language: "en"
guide: "React, Vue, Angular (+ backend)"
step: "Quickstart step 1 of 4, required"
---

# Your frontend

Install and set up the Block-Auth widget in your React, Vue or Angular app.

## Your environment variables

Before you touch any code, create the `.env` files for your frontend and your backend. Your `apiKey` is public and goes in the frontend; your `apiSecret` goes only in the backend. Here they are with your data:

#### Vite (React · Vue) · development

This is your frontend’s `.env`. The backend has its own file.

**.env, next to the frontend package.json**

```dotenv
VITE_BLOCKAUTH_API_KEY=your_api_key
```

#### Vite (React · Vue) · production

It’s baked into the build, so it must exist where you build for production. Pick how you build:

**File · .env.production · in your frontend folder**

```dotenv
VITE_BLOCKAUTH_API_KEY=your_api_key
```

**Docker · Dockerfile · right before npm run build**

```dotenv
ARG VITE_BLOCKAUTH_API_KEY
RUN npm run build
```

**Docker · docker-compose.yml · in the service that builds your frontend**

```dotenv
build:
  args:
    VITE_BLOCKAUTH_API_KEY: ${BLOCKAUTH_API_KEY}
```

**CI · Variable of your CI · in the job that runs npm run build**

```dotenv
VITE_BLOCKAUTH_API_KEY=your_api_key
```

#### Next.js (React) · development

This is your frontend’s `.env.local`. The backend has its own file.

**.env.local, at the project root**

```dotenv
NEXT_PUBLIC_BLOCKAUTH_API_KEY=your_api_key
```

#### Next.js (React) · production

It’s baked into the build, so it must exist where you build for production. Pick how you build:

**File · .env.production · in your frontend folder**

```dotenv
NEXT_PUBLIC_BLOCKAUTH_API_KEY=your_api_key
```

**Docker · Dockerfile · right before npm run build**

```dotenv
ARG NEXT_PUBLIC_BLOCKAUTH_API_KEY
RUN npm run build
```

**Docker · docker-compose.yml · in the service that builds your frontend**

```dotenv
build:
  args:
    NEXT_PUBLIC_BLOCKAUTH_API_KEY: ${BLOCKAUTH_API_KEY}
```

**CI · Variable of your CI · in the job that runs npm run build**

```dotenv
NEXT_PUBLIC_BLOCKAUTH_API_KEY=your_api_key
```

#### Create React App (React) · development

This is your frontend’s `.env`. The backend has its own file.

**.env, at the project root**

```dotenv
REACT_APP_BLOCKAUTH_API_KEY=your_api_key
```

#### Create React App (React) · production

It’s baked into the build, so it must exist where you build for production. Pick how you build:

**File · .env.production · in your frontend folder**

```dotenv
REACT_APP_BLOCKAUTH_API_KEY=your_api_key
```

**Docker · Dockerfile · right before npm run build**

```dotenv
ARG REACT_APP_BLOCKAUTH_API_KEY
RUN npm run build
```

**Docker · docker-compose.yml · in the service that builds your frontend**

```dotenv
build:
  args:
    REACT_APP_BLOCKAUTH_API_KEY: ${BLOCKAUTH_API_KEY}
```

**CI · Variable of your CI · in the job that runs npm run build**

```dotenv
REACT_APP_BLOCKAUTH_API_KEY=your_api_key
```

#### Angular (environment.ts) · development

Angular doesn’t use .env: your apiKey goes in this file. The backend variables go in their own file, your backend’s `.env`.

**src/environments/environment.ts**

```typescript
export const environment = {
  blockauthApiKey: 'your_api_key',
}
```

#### Angular (environment.ts) · production

Keep `environment.ts` with the development key and put the production one in `environment.prod.ts`, next to it. Then tell `angular.json` to swap them in the production build (`ng build`, the default configuration), so development keeps working on `localhost`.

**src/environments/environment.prod.ts · new file**

```typescript
export const environment = {
  blockauthApiKey: 'your_api_key',
}
```

**angular.json · inside projects › your-app › architect › build › configurations › production**

```dotenv
"fileReplacements": [
  {
    "replace": "src/environments/environment.ts",
    "with": "src/environments/environment.prod.ts"
  }
]
```

#### apiKey written in the widget config (React · Vue · Angular) · development and production

Your apiKey goes straight into the widget config (next step), no environment file.

In the widget config, read the apiKey from that variable instead of writing `your_api_key`:

- Vite (`src/main.jsx · src/main.ts`): `apiKey: import.meta.env.VITE_BLOCKAUTH_API_KEY,`
- Next.js (`app/layout.tsx`): `apiKey: process.env.NEXT_PUBLIC_BLOCKAUTH_API_KEY,`
- Create React App (`src/index.js`): `apiKey: process.env.REACT_APP_BLOCKAUTH_API_KEY,`
- Angular (`src/app/app.config.ts`): `apiKey: environment.blockauthApiKey,`

> **Placeholders in this code:**
>
> - Replace `your_api_key` with your API Key, or fill in your data in the SDK Quickstart and it is filled in for you.

`APP_URL` in development is the URL where your frontend runs: Vite `http://localhost:5173`, Next.js `http://localhost:3000`, Create React App `http://localhost:3000`, Angular `http://localhost:4200`.

#### Node.js · development

In a .env next to your backend package.json. Load it with `node --env-file=.env` (Node 20.6+) or the `dotenv` package (`import 'dotenv/config'` at the top of your entry file).

**Your backend’s .env · in your backend folder**

```dotenv
APP_URL=http://localhost:5173
BLOCKAUTH_API_KEY=your_api_key
BLOCKAUTH_API_SECRET=<paste the API Secret from the Dashboard>
SESSION_SECRET=<generate one: openssl rand -hex 32>
```

#### Node.js · production

Set them in your server or platform (Docker, your hosting…), not in a file you upload with your code.

**Environment variables on your server**

```dotenv
APP_URL=https://your-app.com
BLOCKAUTH_API_KEY=your_api_key
BLOCKAUTH_API_SECRET=<paste the API Secret from the Dashboard>
SESSION_SECRET=<generate one: openssl rand -hex 32>
```

#### PHP · development

getenv() doesn't read .env files by itself: set them in your server (`SetEnv` in Apache, `env[]` in PHP-FPM), or load the .env with `vlucas/phpdotenv`.

**Your backend’s .env · in your backend folder**

```dotenv
APP_URL=http://localhost:5173
BLOCKAUTH_API_KEY=your_api_key
BLOCKAUTH_API_SECRET=<paste the API Secret from the Dashboard>
```

#### PHP · production

Set them in your server or platform (Docker, your hosting…), not in a file you upload with your code.

**Environment variables on your server**

```dotenv
APP_URL=https://your-app.com
BLOCKAUTH_API_KEY=your_api_key
BLOCKAUTH_API_SECRET=<paste the API Secret from the Dashboard>
```

#### Python (Flask) · development

In a .env in your backend folder. `flask run` loads it if `python-dotenv` is installed; with `python app.py`, gunicorn or waitress, call `load_dotenv()` first, use `uv run --env-file .env …` or export the variables.

**Your backend’s .env · in your backend folder**

```dotenv
APP_URL=http://localhost:5173
BLOCKAUTH_API_KEY=your_api_key
BLOCKAUTH_API_SECRET=<paste the API Secret from the Dashboard>
SESSION_SECRET=<generate one: openssl rand -hex 32>
```

#### Python (Flask) · production

Set them in your server or platform (Docker, your hosting…), not in a file you upload with your code.

**Environment variables on your server**

```dotenv
APP_URL=https://your-app.com
BLOCKAUTH_API_KEY=your_api_key
BLOCKAUTH_API_SECRET=<paste the API Secret from the Dashboard>
SESSION_SECRET=<generate one: openssl rand -hex 32>
```

#### Python (FastAPI) · development

In a .env in your backend folder. Start uvicorn with `--env-file .env` (needs `python-dotenv` installed) or, with uv, `uv run --env-file .env uvicorn …`, or export the variables.

**Your backend’s .env · in your backend folder**

```dotenv
APP_URL=http://localhost:5173
BLOCKAUTH_API_KEY=your_api_key
BLOCKAUTH_API_SECRET=<paste the API Secret from the Dashboard>
SESSION_SECRET=<generate one: openssl rand -hex 32>
```

#### Python (FastAPI) · production

Set them in your server or platform (Docker, your hosting…), not in a file you upload with your code.

**Environment variables on your server**

```dotenv
APP_URL=https://your-app.com
BLOCKAUTH_API_KEY=your_api_key
BLOCKAUTH_API_SECRET=<paste the API Secret from the Dashboard>
SESSION_SECRET=<generate one: openssl rand -hex 32>
```

#### .NET · development

The public values go in `appsettings.json`. The secret never goes in a file you commit: in development use `user-secrets`, in production an environment variable.

**appsettings.json**

```json
{
  "APP_URL": "http://localhost:5173",
  "BLOCKAUTH_API_KEY": "your_api_key"
}
```

**Terminal, in the project folder (development only)**

```bash
dotnet user-secrets init
dotnet user-secrets set "BLOCKAUTH_API_SECRET" "<paste the API Secret from the Dashboard>"
```

#### .NET · production

Set them in your server or platform (Docker, your hosting…), not in a file you upload with your code.

**appsettings.json**

```json
{
  "APP_URL": "https://your-app.com",
  "BLOCKAUTH_API_KEY": "your_api_key"
}
```

**Environment variable on your server (never in a repo file)**

```dotenv
BLOCKAUTH_API_SECRET=<paste the API Secret from the Dashboard>
```

> **Placeholders in this code:**
>
> - Replace the API Secret placeholder with your API Secret, copied straight from the Dashboard. Never paste it on this site.
> - Replace the SESSION\_SECRET placeholder with a random value generated on your computer: `openssl rand -hex 32`.
> - Replace `your_api_key` with your API Key, or fill in your data in the SDK Quickstart and it is filled in for you.
> - Replace `https://your-app.com` with your app URL, or fill in your data in the SDK Quickstart and it is filled in for you.

## Install the widget

Run it in your **frontend** folder, the one that already has the `package.json` of your React, Vue or Angular app. If your frontend is in a subfolder, like `frontend/` or `client/`, go into it first. If frontend and backend share one `package.json`, it's the project root:

**React · Terminal · in your frontend package.json folder**

```bash
npm install @block-auth.io/react
```

**Vue · Terminal · in your frontend package.json folder**

```bash
npm install @block-auth.io/vue
```

**Angular · Terminal · in your frontend package.json folder**

```bash
npm install @block-auth.io/angular
```

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 frontend 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.

**Only for Angular:**

**angular.json · At the root of your Angular project**

```json
{
  "projects": {
    "your-app": {
      "architect": {
        "build": {
          "options": {
            "allowedCommonJsDependencies": ["crypto-js", "qrcode", "bs58", "socket.io-client"],
            "externalDependencies": [
              "@base-org/account",
              "@coinbase/wallet-sdk",
              "@metamask/connect-evm",
              "porto",
              "porto/internal",
              "@safe-global/safe-apps-provider",
              "@safe-global/safe-apps-sdk",
              "@walletconnect/ethereum-provider"
            ]
          },
          "configurations": {
            "production": {
              "budgets": [
                { "type": "initial", "maximumWarning": "2MB", "maximumError": "3MB" }
              ]
            }
          }
        }
      }
    }
  }
}
```

> **Placeholders in this code:**
>
> - Replace `your-app` with your project name: the key you already have under `projects` in your `angular.json`.

## 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. Your app doesn't change: in React you wrap it as is, with everything it already has inside, and in Vue you add the `.use()` to the chain you already have (for example, next to `.use(router)`), before `.mount()`.

**For every setup except React + Next.js:**

**React · src/main.jsx · where your app starts**

```jsx
import { createRoot } from 'react-dom/client'
import { BlockAuthProvider } from '@block-auth.io/react'
import { App } from './App'

const config = {
  apiKey: 'your_api_key',
  locale: 'en',
}

createRoot(document.getElementById('root')).render(
  <BlockAuthProvider config={config}>
    <App />
  </BlockAuthProvider>,
)
```

**Vue · src/main.ts (or main.js) · where your app starts**

```typescript
import { createApp } from 'vue'
import { createBlockAuth } from '@block-auth.io/vue'
import App from './App.vue'

createApp(App)
  .use(
    createBlockAuth({
      apiKey: 'your_api_key',
      locale: 'en',
    }),
  )
  .mount('#app')
```

**Angular · src/app/app.config.ts**

```typescript
import { ApplicationConfig } from '@angular/core'
import { provideBlockAuth } from '@block-auth.io/angular'

export const appConfig: ApplicationConfig = {
  providers: [
    provideBlockAuth({
      apiKey: 'your_api_key',
      locale: 'en',
    }),
  ],
}
```

> **Placeholders in this code:**
>
> - Replace `your_api_key` with your API Key, or fill in your data in the SDK Quickstart and it is filled in for you.

**Only for React + Next.js:**

In Next.js (App Router), the provider goes in a Client Component. Create `app/providers.jsx` and use it in your root `layout`, wrapping `children`. Tested with Next.js 16; with webpack instead of Turbopack (Next.js 15, or `next build --webpack`) the build fails today, so use Turbopack.

**React · app/providers.jsx · new file**

```jsx
'use client'

import { BlockAuthProvider } from '@block-auth.io/react'

const config = {
  apiKey: 'your_api_key',
  locale: 'en',
}

export function Providers({ children }) {
  return <BlockAuthProvider config={config}>{children}</BlockAuthProvider>
}
```

> **Placeholders in this code:**
>
> - Replace `your_api_key` with your API Key, or fill in your data in the SDK Quickstart and it is filled in for you.

**React · app/layout.jsx · your root layout**

```jsx
import { Providers } from './providers'

export default function RootLayout({ children }) {
  return (
    <html lang="en">
      <body>
        <Providers>{children}</Providers>
      </body>
    </html>
  )
}
```

Any component that uses `FlowBlockAuth` or the hooks also starts with `'use client'`.

**Only for React + Create React App:**

**CRA:** the build warns `Can't resolve '@walletconnect/ethereum-provider'`, an optional dependency the widget doesn't use. You can ignore it; with `CI=true`, CRA turns warnings into errors, so build with `CI=false`.

> **Note:** Never put the `apiSecret` in your frontend, not even in an environment
> variable like `VITE_…` or `NEXT_PUBLIC_…`: the bundler copies it into the
> JavaScript every visitor downloads. The widget doesn't need it: if you pass
> it, the SDK sends it from the browser.

### Config options

- `apiKey` _(string, required)_: your app's API key. It's public: it only says which app is calling.
- `authEndpoint` _(string | false)_: base path of your [backend routes](/sdk-integration-spa-backend.md#backend-routes). By default `/auth/blockauth`: set it only if your routes live under another path, and set the same path as `basePath` in your backend package. To turn off a package route you don’t use, pass `routes: { link: false }` (in .NET, `DisabledRoutes`). Serve it from the same origin as your frontend, so the session cookie travels with every request. If a route is missing or doesn't answer, the browser console says what to fix. Set it to `false` only if your app has no backend: the widget then signs the user in by itself, and your page knows their address but your server has no session it can trust.
- `locale` _(string)_: language of the widget, `"en"` or `"es"`. By default, the browser's language.
- `sessionCheckSeconds` _(number)_: how often the widget asks `/me` whether the session is still open, besides every time the tab gets focus. By default `60`; `0` turns it off.
- `onSessionEnded` _(function)_: called when your backend has closed the session, for example after the user signed out from Block-Auth Identity or the extension. The widget already shows the user as signed out: use it to leave private pages.
- `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.

> Your app today: this page covers “It already has a login” or “It has no login”. Both variants are written out below, each one marked. Follow only the one that matches the app.

## Add the login button

### Your app today: It already has a login.

Put `FlowBlockAuth` on your login page, below your form, as another way in. **Don't replace your page:** add only the `FlowBlockAuth` import and the component right after your form (in Vue and Angular, also the `onSuccess` and `onError` functions). In the example, the `<form>` is your current form, which stays the same. After the login, reload the page: your app asks your backend again who the user is, and your backend resolves it with [your session or Block-Auth's](/sdk-integration-spa-session.md#protect-routes).

**React · Example · your login page with the button added**

```jsx
import { FlowBlockAuth } from '@block-auth.io/react'

export function LoginPage() {
  return (
    <main>
      <form method="post" action="/login">
        <input name="email" type="email" />
        <input name="password" type="password" />
        <button type="submit">Sign in</button>
      </form>
      <FlowBlockAuth
        onSuccess={() => window.location.assign('/')}
        onError={() => alert('Sign-in failed, try again.')}
      />
    </main>
  )
}
```

**Vue · Example · your login page with the button added**

```vue
<script setup>
import { FlowBlockAuth } from '@block-auth.io/vue'

const onSuccess = () => window.location.assign('/')
const onError = () => alert('Sign-in failed, try again.')
</script>

<template>
  <main>
    <form method="post" action="/login">
      <input name="email" type="email" />
      <input name="password" type="password" />
      <button type="submit">Sign in</button>
    </form>
    <FlowBlockAuth :on-success="onSuccess" :on-error="onError" />
  </main>
</template>
```

**Angular · Example · your login page with the button added**

```typescript
import { Component } from '@angular/core'
import { FlowBlockAuthComponent } from '@block-auth.io/angular'

@Component({
  selector: 'app-login-page',
  imports: [FlowBlockAuthComponent],
  template: `
    <main>
      <form method="post" action="/login">
        <input name="email" type="email" />
        <input name="password" type="password" />
        <button type="submit">Sign in</button>
      </form>
      <ba-flow-block-auth (success)="onSuccess()" (errored)="onError()" />
    </main>
  `,
})
export class LoginPageComponent {
  onSuccess(): void {
    window.location.assign('/')
  }

  onError(): void {
    alert('Sign-in failed, try again.')
  }
}
```

**Only for Angular:**

**Angular with `templateUrl`:** the examples put the HTML inside `template`. If your component has its HTML in its own file (`templateUrl`, the default in new Angular projects, like `app.ts` and `app.html`), move what's inside `template` to that `.html` file and keep the rest (`imports` and the methods) in the `.ts` file.

**When signing out**, also close the Block-Auth session: in the function where you already sign out, add a call to `POST /auth/blockauth/logout` with a JSON `{}` body. It works the same in React, Vue and Angular. In the example, `/api/logout` is your current logout, which stays the same:

**Logout · Example · your logout function with the call added**

```javascript
async function logout() {
  await fetch('/api/logout', { method: 'POST' })
  await fetch('/auth/blockauth/logout', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: '{}',
  })
  window.location.assign('/login')
}
```

To let your current users reach their same account, [link them](/sdk-integration-spa-extras.md#link-users).

### Your app today: It has no login.

Place `FlowBlockAuth` where you want the sign-in button. After the login it turns into the profile menu, and on reload it restores the session by asking your backend.

**React · Your header · e.g. src/components/Header.jsx**

```jsx
import { FlowBlockAuth } from '@block-auth.io/react'

export function Header() {
  return (
    <header>
      <FlowBlockAuth
        onSuccess={(address) => console.log('Signed in as', address)}
        onError={() => alert('Sign-in failed, try again.')}
        onLogout={() => window.location.assign('/')}
      />
    </header>
  )
}
```

**Vue · Your header · e.g. src/components/AppHeader.vue**

```vue
<template>
  <header>
    <FlowBlockAuth :on-success="onSuccess" :on-error="onError" :on-logout="onLogout" />
  </header>
</template>

<script setup>
import { FlowBlockAuth } from '@block-auth.io/vue'

const onSuccess = (address) => console.log('Signed in as', address)
const onError = () => alert('Sign-in failed, try again.')
const onLogout = () => window.location.assign('/')
</script>
```

**Angular · Your header · e.g. src/app/header.component.ts**

```typescript
import { Component } from '@angular/core'
import { FlowBlockAuthComponent } from '@block-auth.io/angular'

@Component({
  selector: 'app-header',
  imports: [FlowBlockAuthComponent],
  template: `
    <header>
      <ba-flow-block-auth
        (success)="onSuccess($event)"
        (errored)="onError()"
        (loggedOut)="onLogout()"
      />
    </header>
  `,
})
export class HeaderComponent {
  onSuccess(address?: string): void {
    console.log('Signed in as', address)
  }

  onError(): void {
    alert('Sign-in failed, try again.')
  }

  onLogout(): void {
    window.location.assign('/')
  }
}
```

**Only for Angular:**

**Angular with `templateUrl`:** the examples put the HTML inside `template`. If your component has its HTML in its own file (`templateUrl`, the default in new Angular projects, like `app.ts` and `app.html`), move what's inside `template` to that `.html` file and keep the rest (`imports` and the methods) in the `.ts` file.

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.

**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](/sdk-integration-spa-go-live.md#production-csp).

## Checklist

Go over these before moving on to the backend. They adapt to your framework and your choices:

The checklist depends on the framework and the choices. Every combination is listed below.

#### React · Vite

- **The package is installed**: `@block-auth.io/react` shows up in your frontend `package.json`, not in a new one created elsewhere.
- **`BlockAuthProvider` wraps your whole app**: in `src/main.jsx`.
- If the apiKey is in an environment variable: **Your apiKey comes from `VITE_BLOCKAUTH_API_KEY`**: in `.env`, read with `import.meta.env.VITE_BLOCKAUTH_API_KEY`. If a change doesn’t apply, restart `npm run dev`.
- If the apiKey is written in the widget config: **Your apiKey is in the widget config**: replacing `your_api_key`.
- If “Your app today” is “It already has a login”: **The button sits next to your login form**: `<FlowBlockAuth />` on your login page, reloading the page in `onSuccess`.
- If “Your app today” is “It has no login”: **The button is where you want it**: `<FlowBlockAuth />`, for example in your header.
- If “Your app today” is “It already has a login”: **Your logout also closes the Block-Auth session**: with a `POST /auth/blockauth/logout` and a JSON `{}` body, after your own logout.
- If “Your app today” is “It has no login”: **The widget handles the logout**: after the login the button becomes the profile menu, with its own sign out.
- If the apiKey is in an environment variable: **The `apiSecret` isn’t in the frontend**: not even in a `VITE_…` variable: it only goes in your backend.
- If the apiKey is written in the widget config: **The `apiSecret` isn’t in the frontend**: in no frontend file or config: it only goes in your backend.

#### React · Next.js

- **The package is installed**: `@block-auth.io/react` shows up in your frontend `package.json`, not in a new one created elsewhere.
- **`BlockAuthProvider` wraps your whole app**: in `app/providers.jsx`.
- If the apiKey is in an environment variable: **Your apiKey comes from `NEXT_PUBLIC_BLOCKAUTH_API_KEY`**: in `.env.local`, read with `process.env.NEXT_PUBLIC_BLOCKAUTH_API_KEY`. If a change doesn’t apply, restart `npm run dev`.
- If the apiKey is written in the widget config: **Your apiKey is in the widget config**: replacing `your_api_key`.
- If “Your app today” is “It already has a login”: **The button sits next to your login form**: `<FlowBlockAuth />` on your login page, reloading the page in `onSuccess`.
- If “Your app today” is “It has no login”: **The button is where you want it**: `<FlowBlockAuth />`, for example in your header.
- If “Your app today” is “It already has a login”: **Your logout also closes the Block-Auth session**: with a `POST /auth/blockauth/logout` and a JSON `{}` body, after your own logout.
- If “Your app today” is “It has no login”: **The widget handles the logout**: after the login the button becomes the profile menu, with its own sign out.
- If the apiKey is in an environment variable: **The `apiSecret` isn’t in the frontend**: not even in a `NEXT_PUBLIC_…` variable: it only goes in your backend.
- If the apiKey is written in the widget config: **The `apiSecret` isn’t in the frontend**: in no frontend file or config: it only goes in your backend.

#### React · Create React App

- **The package is installed**: `@block-auth.io/react` shows up in your frontend `package.json`, not in a new one created elsewhere.
- **`BlockAuthProvider` wraps your whole app**: in `src/index.js`.
- If the apiKey is in an environment variable: **Your apiKey comes from `REACT_APP_BLOCKAUTH_API_KEY`**: in `.env`, read with `process.env.REACT_APP_BLOCKAUTH_API_KEY`. If a change doesn’t apply, restart `npm start`.
- If the apiKey is written in the widget config: **Your apiKey is in the widget config**: replacing `your_api_key`.
- If “Your app today” is “It already has a login”: **The button sits next to your login form**: `<FlowBlockAuth />` on your login page, reloading the page in `onSuccess`.
- If “Your app today” is “It has no login”: **The button is where you want it**: `<FlowBlockAuth />`, for example in your header.
- If “Your app today” is “It already has a login”: **Your logout also closes the Block-Auth session**: with a `POST /auth/blockauth/logout` and a JSON `{}` body, after your own logout.
- If “Your app today” is “It has no login”: **The widget handles the logout**: after the login the button becomes the profile menu, with its own sign out.
- If the apiKey is in an environment variable: **The `apiSecret` isn’t in the frontend**: not even in a `REACT_APP_…` variable: it only goes in your backend.
- If the apiKey is written in the widget config: **The `apiSecret` isn’t in the frontend**: in no frontend file or config: it only goes in your backend.

#### Vue · Vite

- **The package is installed**: `@block-auth.io/vue` shows up in your frontend `package.json`, not in a new one created elsewhere.
- **`createBlockAuth(...)` is registered**: with `.use()` before `.mount()`, in `src/main.ts` (or `main.js`).
- If the apiKey is in an environment variable: **Your apiKey comes from `VITE_BLOCKAUTH_API_KEY`**: in `.env`, read with `import.meta.env.VITE_BLOCKAUTH_API_KEY`. If a change doesn’t apply, restart `npm run dev`.
- If the apiKey is written in the widget config: **Your apiKey is in the widget config**: replacing `your_api_key`.
- If “Your app today” is “It already has a login”: **The button sits next to your login form**: `<FlowBlockAuth />` on your login page, reloading the page in `:on-success`.
- If “Your app today” is “It has no login”: **The button is where you want it**: `<FlowBlockAuth />`, for example in your header.
- If “Your app today” is “It already has a login”: **Your logout also closes the Block-Auth session**: with a `POST /auth/blockauth/logout` and a JSON `{}` body, after your own logout.
- If “Your app today” is “It has no login”: **The widget handles the logout**: after the login the button becomes the profile menu, with its own sign out.
- If the apiKey is in an environment variable: **The `apiSecret` isn’t in the frontend**: not even in a `VITE_…` variable: it only goes in your backend.
- If the apiKey is written in the widget config: **The `apiSecret` isn’t in the frontend**: in no frontend file or config: it only goes in your backend.

#### Angular

- **The package is installed**: `@block-auth.io/angular` shows up in your frontend `package.json`, not in a new one created elsewhere.
- **`angular.json` has the widget dependencies**: `allowedCommonJsDependencies` and `externalDependencies` in the build options, and an `initial` budget of 2 MB in production.
- **`provideBlockAuth(...)` is in your providers**: in `src/app/app.config.ts`.
- If the apiKey is in an environment variable: **Your apiKey comes from `environment.blockauthApiKey`**: in `src/environments/environment.ts`, imported in `app.config.ts`.
- If the apiKey is written in the widget config: **Your apiKey is in the widget config**: replacing `your_api_key`.
- If “Your app today” is “It already has a login”: **The button sits next to your login form**: `<ba-flow-block-auth>` on your login page, reloading the page in `(success)`.
- If “Your app today” is “It has no login”: **The button is where you want it**: `<ba-flow-block-auth>`, for example in your header.
- If “Your app today” is “It already has a login”: **Your logout also closes the Block-Auth session**: with a `POST /auth/blockauth/logout` and a JSON `{}` body, after your own logout.
- If “Your app today” is “It has no login”: **The widget handles the logout**: after the login the button becomes the profile menu, with its own sign out.
- If the apiKey is in an environment variable: **The `apiSecret` isn’t in the frontend**: not even in `environment.ts`: it only goes in your backend.
- If the apiKey is written in the widget config: **The `apiSecret` isn’t in the frontend**: in no frontend file or config: it only goes in your backend.

Login doesn’t work yet: your backend is missing. You test it end to end in the last step, [Connect and try it](/sdk-integration-spa-connect.md#try-it).

Next step: [Your backend](/sdk-integration-spa-backend.md)
