Integration path · Phase one

Browser SDK

Embed a published campaign.

Add voting and direct recipient donations to an existing website with one public campaign ID. A developer project is not required for this phase.

Get the public campaign ID

Publish the campaign in Our Impact, open its embed page, and copy the value after /embed/. The public ID is safe to include in browser code and is different from the campaign’s internal database ID.

Install and mount

1

Install the browser SDK

Terminal
pnpm add @our-impact/browser
2

Create a client component

components/community-campaign.tsx
"use client";

import { mountCampaign, type CampaignWidgetStatus } from "@our-impact/browser";
import { useEffect, useRef, useState } from "react";

export function CommunityCampaign({ publicId }: { publicId: string }) {
  const target = useRef<HTMLDivElement>(null);
  const [status, setStatus] = useState<CampaignWidgetStatus>("loading");

  useEffect(() => {
    if (!target.current) return;

    const campaign = mountCampaign({
      target: target.current,
      publicId,
      title: "Vote in our community campaign",
      height: "auto",
      minHeight: 520,
      borderRadius: 20,
      onStatusChange: setStatus,
    });

    return () => campaign.destroy();
  }, [publicId]);

  return (
    <section aria-busy={status === "loading"}>
      <div ref={target} />
      {status === "error" && <p role="alert">Campaign unavailable.</p>}
    </section>
  );
}
3

Render it on the page

Pass the public ID from configuration and place the component wherever the campaign should appear. Always destroy the returned widget during component cleanup.

Widget options

The browser SDK owns iframe creation, safe message handling, and automatic height updates.

widget-options.ts
mountCampaign({
  target: "#community-campaign", // HTMLElement or selector
  publicId: "your-public-campaign-id",
  title: "Community campaign",   // iframe accessible name
  height: "auto",               // or a fixed pixel value
  minHeight: 420,
  maxHeight: 900,
  borderRadius: 24,
  onStatusChange(status) {
    // loading | ready | identified | anonymous | error
  },
});

Production checklist

  • The campaign is published and has active recipients.
  • The public ID comes from the embed URL.
  • The target element exists before mounting.
  • The widget is destroyed during route or component cleanup.
  • The iframe has a meaningful title.
  • Loading and error states are visible to the user.