Followers

BusinessDash's followers system manages newsletter subscribers and community members.

SDK access (publishable token)

import { useFollowers } from '@businessdash/sdk/react'

function SubscribeForm() {
  const { join, me, edit, leave } = useFollowers({
    pk: process.env.NEXT_PUBLIC_BD_PK,
    siteId: process.env.NEXT_PUBLIC_BD_SITE_ID,
  })

  return (
    <form onSubmit={async (e) => {
      e.preventDefault()
      await join({ email: 'jane@example.com', name: 'Jane' })
    }}>
      <input name="email" type="email" required />
      <button type="submit">Subscribe</button>
    </form>
  )
}

Server-side (full API key)

// Fetch the current follower
const follower = await client.followers.me('follower-id')

// Update preferences
await client.followers.edit('follower-id', { tags: ['newsletter', 'promo'] })

// Unsubscribe
await client.followers.leave('follower-id')

The join() method uses the publishable token (origin-locked, rate-limited) and is safe to call from the browser. The me/edit/leave methods can use either the publishable token or a full API key depending on your setup.