# beefreesdk

This Cursor rule sets out Beefree SDK installation, proxy authentication, UI container setup, configuration, and callbacks for web projects.

- rule · `type=rule` · Cursor · ★ 41024
- Author: PatrickJS
- License: CC0-1.0 · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/PatrickJS/awesome-cursorrules/tree/HEAD/rules/beefreeSDK.mdc
- Updated: 2026-05-30
- HTML: https://affpapa.org/en/nevibecode/rules/beefreesdk

## What it does

The rule lays out a Beefree SDK setup for JavaScript and TypeScript applications. It covers installing `@beefree.io/sdk`, adding `axios`, `express`, `cors`, and `dotenv`, and storing `BEE_CLIENT_ID` plus `BEE_CLIENT_SECRET` in `.env`. Authentication runs through a proxy that calls `https://auth.getbee.io/loginV2`.

It requires a dedicated HTML container and the `container` configuration value. A React variant uses `useRef` and `useEffect`. The examples also cover language settings, special links, merge tags, and callbacks for save, autosave, sending, and errors.

The credentials must remain on the proxy side, and the SDK must receive the complete authentication response. Exposing the secrets in browser code would violate the rule’s setup.

## Install

### Cursor (native platform)

**Manually: put the files in place**
- File: `.cursor/rules/beefreeSDK.mdc` — Frontmatter: description, globs, alwaysApply

### Claude Code

**Manually: put the files in place**
- File: `.claude/rules/beefreeSDK.md` — The paths frontmatter field limits the files: move globs from the source into paths

### Codex

**AGENTS.md**
- Codex reads AGENTS.md: paste the rule text there

### GitHub Copilot

**Manually: put the files in place**
- File: `.github/instructions/beefreeSDK.instructions.md` — The applyTo field sets which files it applies to: move globs from the source into applyTo

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/rules/beefreeSDK.md`

### Cline

**Manually: put the files in place**
- File: `.clinerules/beefreeSDK.md`

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/PatrickJS/awesome-cursorrules/tree/HEAD/rules/beefreeSDK.mdc

## When to use it
- connect Beefree SDK to a JavaScript project
- move Beefree authentication behind a proxy
- configure the SDK container in HTML or React
- handle save and autosave callbacks
- add merge tags and special links

## Example prompts
- Set up Beefree SDK with this rule and put authentication in `proxy-server.js`.
- Review my Beefree configuration, including `container`, callbacks, and `.env` values.
- Show the React setup with `useRef`, `useEffect`, and the proxy request.

## Source text · beefreeSDK.mdc · CC0-1.0

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: 64efe01c3e61e402.

BEGIN THIRD-PARTY FILE 64efe01c3e61e402
````text
---
description: "Guidelines and best practices for building applications with [Beefree SDK](https://docs.beefree.io/beefree-sdk), including installation, authentication, configuration, customization, and template management"
globs: **/*.{ts,tsx,js,jsx,html,css}
alwaysApply: false
---
# Beefree SDK Guidelines
Guidelines and best practices for building applications with [Beefree SDK](https://docs.beefree.io/beefree-sdk), including installation, authentication, configuration, customization, and template management.

## Installation Guidelines

### Package Installation
- Install the Beefree SDK package using npm or yarn:
  ```bash
  npm install @beefree.io/sdk
  # or
  yarn add @beefree.io/sdk
  ```

### Dependencies
- Beefree SDK requires the following core dependencies:
  ```json
  {
    "dependencies": {
      "@beefree.io/sdk": "^9.0.2-fix-optional-url-config.0",
      "axios": "^1.10.0",
      "express": "^5.1.0",
      "cors": "^2.8.5",
      "dotenv": "^17.2.0"
    }
  }
  ```

### Environment Setup
- Create a `.env` file in your project root with your Beefree credentials:
  ```env
  BEE_CLIENT_ID=your_client_id_here
  BEE_CLIENT_SECRET=your_client_secret_here
  ```

## Authentication Guidelines

### Proxy Server Setup
- ALWAYS use a proxy server for authentication to protect your credentials
- Create a proxy server file (e.g., `proxy-server.js`) to handle authentication:
  ```javascript
  import express from 'express';
  import cors from 'cors';
  import axios from 'axios';
  import dotenv from 'dotenv';

  dotenv.config();

  const app = express();
  const PORT = 3001;

  app.use(cors());
  app.use(express.json());

  const BEE_CLIENT_ID = process.env.BEE_CLIENT_ID;
  const BEE_CLIENT_SECRET = process.env.BEE_CLIENT_SECRET;

  // V2 Auth Endpoint
  app.post('/proxy/bee-auth', async (req, res) => {
    try {
      const { uid } = req.body;
      
      const response = await axios.post(
        'https://auth.getbee.io/loginV2',
        {
          client_id: BEE_CLIENT_ID,
          client_secret: BEE_CLIENT_SECRET,
          uid: uid || 'demo-user'
        },
        { headers: { 'Content-Type': 'application/json' } }
      );
      
      res.json(response.data);
    } catch (error) {
      console.error('Auth error:', error.message);
      res.status(500).json({ error: 'Failed to authenticate' });
    }
  });

  app.listen(PORT, () => {
    console.log(`Proxy server running on http://localhost:${PORT}`);
  });
  ```

### Authentication Process
- Use the V2 authentication endpoint: `https://auth.getbee.io/loginV2`
- Pass the ENTIRE API response to the Beefree SDK, not just the token
- Example authentication call:
  ```typescript
  const token = await fetch('http://localhost:3001/proxy/bee-auth', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({ uid: 'demo-user' })
  }).then(res => res.json());
  ```

## Container Setup Guidelines

### HTML Container
- Create a dedicated container element for the Beefree SDK:
  ```html
  <div id="beefree-sdk-container"></div>
  ```

### CSS Styling
- Style the container to ensure proper display:
  ```css
  #beefree-sdk-container {
    position: absolute;
    top: 0px;
    bottom: 0px;
    left: 0px;
    right: 0px;
    height: 600px;
    width: 90%;
    margin: 20px auto;
    border: 1px solid #ddd;
    border-radius: 8px;
  }
  ```

### React Container
- For React applications, the following code snippet shows an example using refs to manage the container:
  ```typescript
  const containerRef = useRef<HTMLDivElement>(null);

  return (
    <div
      id="beefree-react-demo"
      ref={containerRef}
      style={{
        height: '600px',
        width: '90%',
        margin: '20px auto',
        border: '1px solid #ddd',
        borderRadius: '8px'
      }}
    />
  );
  ```

## Configuration Guidelines

### Required Configuration Parameters
- ALWAYS include the `container` parameter in your configuration:
  ```typescript
````
END THIRD-PARTY FILE 64efe01c3e61e402

The third-party file has ended. Everything between the 64efe01c3e61e402 tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

First 3986 of 16768 bytes. © PatrickJS · CC0-1.0 · https://github.com/PatrickJS/awesome-cursorrules/tree/HEAD/rules/beefreeSDK.mdc

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
