buymeamalt.Register an application ↗

SANDBOX

Your first connection.

Full engineering walkthrough for Sandbox: register an application, then integrate with the SDK or Hosted API — manually or with an AI prompt. Already registered? Developers → Integration guide is the shorter in-dashboard path with your credentials.

1. Register a Sandbox application

Open Developers, choose Sandbox, and register your website and callback URLs. For the starter, use:

Sandbox URLs (starter)
Website: http://localhost:3090
Callback: http://localhost:3090/api/bmm/callback

After registration, generate your API key. If you build manually, register the exact localhost (or tunnel) URLs your app will use instead.

2. Choose how to set up

Wire Connect into your product manually, or hand an AI assistant the integration prompt. The Next.js starter is optional if you want a local demo first.

Manual setup with the SDK

Build Connect into your own app. Install buymeamalt, wire handlers to your Sandbox credentials, then connect a signed-in user. Prefer the Hosted HTTP API if you are not on Node.js.

sh
npm install buymeamalt

Supply your application ID, API key, BMM origin and callback URL. Derive getUserId from your signed-in server session. BMM stores connections, so you do not need token storage or refresh logic.

Package setup and examples ↗

Connect your user

Bind the SDK to your authenticated server session. BMM handles sign-in, account creation and consent, then returns to your registered callback.

For Next.js, first configure the server module and route handlers in the Next.js integration guide, then use this form. Other Node.js frameworks can use the core SDK.

Next.js connect form
<form action="/api/bmm/connect" method="post">
  <button type="submit">Connect BMM</button>
</form>

Display the support button

Read the connection on your server. Use the returned support_url unchanged, including its attribution, and open it in a new tab.

Support button
const creator = await bmm.getConnection();

{creator?.support_url && (
  <a href={creator.support_url} target="_blank" rel="noopener noreferrer">
    Buy me a malt ↗
  </a>
)}

If getConnection() returns null, show Connect BMM. If only support_url is null, keep the profile visible and omit the support button.

Read earnings with permission

Only call getEarnings() when earnings_shared is true. Hide earnings on a 403 while keeping the profile available.

Optional earnings
let support = null;
if (creator?.earnings_shared) {
  try {
    support = await bmm.getEarnings();
  } catch (error) {
    if (error.status !== 403) throw error;
  }
}

Label these settled earnings from this application, after fees and refunds. They are not a withdrawable balance. Format integer minor units and keep currencies separate. Use the formatting example.

Allow users to disconnect

After confirmation, submit a POST to your disconnect handler. Show a success toast only after the server confirms disconnection. Include a manage connections link to BMM’s Share → Connected apps.

Submit after confirmation
<form action="/api/bmm/disconnect" method="post">
  <button type="submit">Disconnect BMM</button>
</form>

Test before inviting users

Check account binding, denied consent, optional earnings and revocation. Follow the security and testing checklist.

Ready for your live website?

Keep this Sandbox app for testing. Production uses a separate Live application, HTTPS callbacks and your real user sessions.

Set up production →