> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bludia.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Frontend integration

> Connect any frontend to Bludia over HTTPS: browser and mobile apps use an end_users API key with allowed origins plus the signed-in user's Bearer token; servers can use a platform key. Works with React, Next.js, Vue, Svelte, Flutter, Swift, Kotlin, and any HTTP client.

Bludia is a plain JSON REST API, so any framework or language can use it. No SDK is required.

## Pick an architecture

> [card] Browser or mobile → Bludia
>
> The app calls Bludia directly with an **`end_users`** key and the user's Bearer token. Permissions and row policies protect the data.
>
> Best for SPAs (React, Vue, Svelte) and mobile apps.

> [card] Your server → Bludia
>
> Your server (Next.js, Express, Laravel, Django…) calls Bludia, often with a **`platform`** key, and renders or proxies data to the browser.
>
> Best for SSR, admin tools, and logic you keep on your own server.

```text theme={null}
Direct:   Browser ──(end_users key + Bearer)──► Bludia
Server:   Browser ──► Your server ──(platform key)──► Bludia
Hybrid:   Browser ──(end_users key + Bearer)──► Bludia   (user data)
          Your server ──(platform key)──► Bludia          (admin jobs)
```

## Checklist for a browser app

**1. Create an end\_users key**

Add your origins, for example `http://localhost:5173` and `https://app.example.com`. See [CORS](https://docs.bludia.com/api/cors.md).

**2. Set up a guard and roles**

So users can sign up and have permissions. See [Authentication](https://docs.bludia.com/authentication/overview.md).

**3. Store config in env vars**

```bash .env theme={null}
VITE_BLUDIA_BASE_URL=https://YOUR_API_HOST/ext/api/v1
VITE_BLUDIA_API_KEY=bludia_production_...
VITE_BLUDIA_GUARD=users
```

**4. Add a small client**

Handles headers, token refresh, and errors. See [JavaScript client](https://docs.bludia.com/frontend/javascript-client.md).

**5. Build screens**

Login, sign-up, lists, and forms. See [React](https://docs.bludia.com/frontend/react.md).

> [!WARNING]
>
> Only `end_users` keys belong in browser or mobile code. A `platform` key bypasses all permissions.

## Guides

> [card] [JavaScript client](https://docs.bludia.com/frontend/javascript-client.md)
>
> A drop-in `fetch` wrapper with auto refresh.

> [card] [React](https://docs.bludia.com/frontend/react.md)
>
> Auth context, protected routes, data hooks.

> [card] [Server-side](https://docs.bludia.com/frontend/server-side.md)
>
> Next.js route handlers, Node, Python.

## Other platforms

| Platform | Notes |
| :- | :- |
| Flutter / Dart | Use `http` or `dio`; store the refresh token with `flutter_secure_storage` |
| iOS (Swift) | `URLSession`; refresh token in Keychain |
| Android (Kotlin) | Retrofit or Ktor; refresh token in EncryptedSharedPreferences |
| Vue, Svelte, Angular | Use the [JavaScript client](https://docs.bludia.com/frontend/javascript-client.md) as is |

Mobile apps don't send an `Origin` header, so allowed origins don't apply to them.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.