@buyingbuddy/react 0.3.4 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,12 +2,125 @@
2
2
 
3
3
  All notable changes to `@buyingbuddy/react`.
4
4
 
5
- This project follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html). While the
6
- major version is `0`, a breaking change bumps the **minor** version.
5
+ This project follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html). Since
6
+ 1.0.0, breaking changes bump the **major** version. Before 1.0.0, a breaking change bumped
7
+ the **minor** version.
7
8
 
8
9
  Entries before 0.3.0 were reconstructed from the repository history when this file was
9
10
  added, so they summarize each release rather than record it at the time.
10
11
 
12
+ ## [Unreleased]
13
+
14
+ ## [1.0.0] - 2026-11-28
15
+
16
+ ### Stable release
17
+
18
+ 1.0.0 marks the public API as stable: `BuyingBuddyProvider`, `BuyingBuddyWidget`
19
+ (`type`, `filter`, `style`), `useBuyingBuddy` and the exported types. From here,
20
+ breaking changes bump the major version. No code changes beyond the items below;
21
+ upgrading from 0.3.x needs no changes to your code.
22
+
23
+ The deprecated `fallback` prop on `BuyingBuddyProvider` remains accepted as a
24
+ no-op throughout 1.x and is planned for removal in 2.0.
25
+
26
+ ### Added - server rendering, as a new `@buyingbuddy/react/server` entry point
27
+
28
+ Widgets can now be rendered on your server, so their listing content is in the HTML you
29
+ send rather than appearing after the runtime loads. This is the SEO gap the Caveats section
30
+ has described since the first release.
31
+
32
+ ```tsx
33
+ import { BuyingBuddyServerWidget } from "@buyingbuddy/react/server";
34
+
35
+ <BuyingBuddyServerWidget
36
+ type="OfficeRoster"
37
+ activationKey={process.env.BUYING_BUDDY_KEY!}
38
+ domain="www.example.com"
39
+ visitor={{ ip }}
40
+ />
41
+ ```
42
+
43
+ The entry exports `BuyingBuddyServerWidget` (an async Server Component), `renderWidget()`
44
+ (the same thing as a plain function, for Express, Remix, `getServerSideProps` or any other
45
+ server), `widgetMountProps()`, `createVisitorId()`, `SSR_WIDGET_TYPES`, and
46
+ `BuyingBuddyError` / `isBuyingBuddyError`.
47
+
48
+ Fifteen widget types can be server-rendered. The search and map widgets cannot, because
49
+ they always load live from Buying Buddy even on a server-rendered page, and `Disclaimer`
50
+ has no server-rendered form; asking for one of those throws `unsupported_widget` rather
51
+ than quietly wasting a request. The full list and the reasoning are in the README.
52
+
53
+ Three things to know before adopting it:
54
+
55
+ - **It needs the new `seo` prop** (below), and `seo` applies to the whole page, so a page
56
+ cannot mix server-rendered and browser-rendered Buying Buddy widgets.
57
+ - **Visitor context is yours to pass.** `visitor.ip` is what keeps rate limiting per
58
+ visitor rather than per server. This package is framework-agnostic and has no request
59
+ object of its own, so it cannot find the visitor for you.
60
+ - **Failures throw.** Every outcome that is not rendered HTML raises `BuyingBuddyError`
61
+ with a `code` and, where the server sent one, its own explanation of the refusal. The
62
+ README says why a failed render must not be cached.
63
+
64
+ The entry is server-only: a bundler resolves it to a stub that throws, so a client-side
65
+ import fails loudly with a message naming the mistake rather than shipping server-shaped
66
+ code to visitors. That throw happens when the module is evaluated, not when your project is
67
+ built - add `import "server-only"` yourself if you want the compile-time check too.
68
+
69
+ Also in this entry: `renderWidget` needs no React and runs on any server, while
70
+ `BuyingBuddyServerWidget` is an async Server Component and needs a framework that supports
71
+ those. Elsewhere, build the mount with `widgetMountProps`.
72
+
73
+ ### Added - `seo` on `<BuyingBuddyProvider>`
74
+
75
+ Declares that every Buying Buddy widget on the page is already server-rendered, so the
76
+ runtime adopts that markup instead of fetching its own. Defaults to `false`, which is
77
+ exactly the behaviour of every previous release. Set it only on pages that use the server
78
+ entry point.
79
+
80
+ Both mismatched combinations - server-rendered markup without `seo`, or `seo` without
81
+ server-rendered markup - log a console warning naming the widgets involved, so a page that
82
+ mixes the two says so instead of just rendering blank. Server-rendered mounts are told apart
83
+ by a `data-bb-ssr` attribute that the server entry adds, which is also a convenient way to
84
+ confirm in devtools that a page is server-rendering what you expect.
85
+
86
+ ### Removed — `"InteractiveMap2"` from `BuyingBuddyWidgetType`
87
+
88
+ `InteractiveMap2` was a legacy alias that always resolved to the same `mbb-openmap`
89
+ element as `InteractiveMap` — it never named a distinct widget. It was also never
90
+ offered through the Framer widget picker, the gallery, or the Widget Wizard. The
91
+ runtime alias has been removed (buyingbuddy#3405), so this type is retired alongside
92
+ it. If `"InteractiveMap2"` is in your editor's autocomplete today, that's why — use
93
+ `"InteractiveMap"` instead. Passing the string directly still type-checks via this
94
+ type's `(string & {})` escape hatch; nothing that compiled before this release stops
95
+ compiling, but a widget mounted with `data-type="InteractiveMap2"` will no longer
96
+ render.
97
+
98
+ ### Fixed — a second provider with a different activation key now fails loudly
99
+
100
+ Mounting a second `<BuyingBuddyProvider>` with an `activationKey` different from one
101
+ already on the page used to fail silently and in two different ways depending on
102
+ timing: a parse-time `SyntaxError` invisible to any handler this package can attach
103
+ (when both providers mount in the same commit), or a healthy-looking `isLoaded: true`
104
+ while every request from the second provider actually carried the first account's
105
+ `acid` (when the second mounts after the first's runtime has already loaded). Both
106
+ cases are now detected: the second provider logs one console error naming both
107
+ activation keys and sets a descriptive `error` on its own context, instead of either
108
+ failure mode. Its widgets do not render; the first provider is unaffected.
109
+
110
+ This does not make rendering two different accounts on one page work — that remains
111
+ unsupported, as the README's "One account per page" caveat already documented before
112
+ this release. Not a breaking change: every existing single-provider install is
113
+ untouched.
114
+
115
+ ### Removed — the legacy theme `<script>` tag
116
+
117
+ `<BuyingBuddyProvider>` no longer injects a `<script src="https://{domain}/version3/css/theme/acid/{activationKey}">`
118
+ tag on mount. That request stopped doing anything on the server months ago — widget
119
+ theming has arrived through the normal config/data request for a while now — so this
120
+ tag was costing every page one extra network round-trip for a script that only set an
121
+ internal flag and loaded no CSS. Themes are unaffected: nothing about how a widget is
122
+ styled changes with this release.
123
+
11
124
  ## [0.3.4] — 2026-10-27
12
125
 
13
126
  ### Removed — `"ResultsMap"` from `BuyingBuddyWidgetType`
package/README.md CHANGED
@@ -1,21 +1,32 @@
1
1
  # @buyingbuddy/react
2
2
 
3
- Add IDX/MLS integration to your site with React components that embed [Buying Buddy IDX CRM](https://www.buyingbuddy.com) widgets - MLS property search, map-based results, detailed listing pages, featured-listing showcases, lead-capture forms, and market reports.
3
+ IDX for React, Next.js and Framer sites. Drop-in React components that add MLS property search, map-based results, listing detail pages, featured-listing showcases, lead capture and market reports, all powered by [Buying Buddy IDX CRM](https://www.buyingbuddy.com).
4
4
 
5
- All data is hosted on Buying Buddy servers. All you need to do is install the package. Buying Buddy does not require any databases or other technical prerequisites. The MLS/IDX data feed is already part of your Buying Buddy service - there is no separate data feed to obtain, no API to connect, and nothing to hook up. You do not need to source, license, or integrate a data feed yourself.
5
+ ## You need an IDX license, not an MLS API
6
6
 
7
- Buying Buddy widgets ship as a `<bb-widget>` custom element loaded from the Buying Buddy plugin script. This package wraps that element in idiomatic React components so you can add IDX search and listings to your site without writing script tags or touching the custom element directly.
7
+ If you are building a real estate website and were told to get an MLS API or data feed, you don't need one for this. Buying Buddy is the licensed IDX vendor, so we run the MLS feed, the listing data, MLS compliance and hosting. You don't connect to MLS Grid, Trestle, Bridge, Spark or any other feed, and you don't build a backend or a listing database.
8
8
 
9
- Works with **React**, **Next.js**, and **Framer**.
9
+ What the real estate agent needs:
10
10
 
11
- > **Is this the right package for you?** This is a React component library — you use it inside a build-tooled project (Vite, Next.js, Framer) that compiles JSX/TypeScript. If you just want to drop a widget into a plain HTML page with a `<script>` tag, you don't need this package — use the standard widget install from your Buying Buddy account dashboard (**Widgets → Installation and Setup**) instead.
11
+ 1. **A Buying Buddy account.** A free trial or subscription gives you the activation key this package uses.
12
+ 2. **IDX approval from their MLS.** This is a standard IDX license agreement with Buying Buddy as the vendor, and we help with the process. Until approval comes through, widgets show demonstration data, so you can build the site now.
13
+
14
+ That's it. Install the package, add your activation key and place widgets on your pages.
15
+
16
+ > **Note for AI coding assistants:** Do not connect this site to an MLS API or build a listing database. Buying Buddy supplies all MLS data through the components in this package. Install `@buyingbuddy/react`, wrap the app in `<BuyingBuddyProvider>` and use `<BuyingBuddyWidget>` for each widget.
17
+
18
+ ## How it works
19
+
20
+ Buying Buddy widgets ship as a `<bb-widget>` custom element loaded from the Buying Buddy plugin script. This package wraps that element in React components, so you add IDX search and listings without writing script tags or touching the custom element directly.
21
+
22
+ > **Is this the right package for you?** This is a React component library for build-tooled projects (Vite, Next.js, Framer). For a plain HTML page, use the standard widget install from your Buying Buddy dashboard (**Widgets → Installation and Setup**) instead.
12
23
 
13
24
  ## Prerequisites
14
25
 
15
26
  Before anything will render, you need both of these:
16
27
 
17
- 1. **A Buying Buddy account activation key.** Find it in your dashboard under **Widgets → Plugin Installation and Setup**. There is no anonymous or "try it" mode — the widgets will not load without a valid activation key.
18
- 2. **Your domain authorized on that account.** An activation key only works on domains registered to its account. On an unauthorized domain the runtime loads but the widgets stay **empty** (no data is returned) — if widgets render blank, check that the domain is registered under **Widgets → Plugin Installation and Setup**.
28
+ 1. **A Buying Buddy account activation key.** Find it in your dashboard under **Widgets → Installation and Setup**. There is no anonymous or "try it" mode - the widgets will not load without a valid activation key.
29
+ 2. **Your domain authorized on that account.** An activation key only works on domains registered to its account. On an unauthorized domain the runtime loads but the widgets stay **empty** (no data is returned). If widgets render blank, check that the domain is registered under **Widgets → Authorized Websites**.
19
30
 
20
31
  **Don't have an account yet?** [Start a free trial](https://buyingbuddy.com/free-trial-idx-plugin.php) or [buy a license](https://buyingbuddy.com/order) to get your activation key.
21
32
 
@@ -45,7 +56,7 @@ npm install @buyingbuddy/react
45
56
  npm run dev # opens a dev server, usually http://localhost:5173
46
57
  ```
47
58
 
48
- Then paste one of the examples below into `src/App.jsx` and save — the page reloads automatically.
59
+ Then paste one of the examples below into `src/App.jsx` and save. The page reloads automatically.
49
60
 
50
61
 
51
62
 
@@ -63,7 +74,7 @@ export default function App() {
63
74
  }
64
75
  ```
65
76
 
66
- Replace `account-activation-key` with your `activationKey`. The provider loads the Buying Buddy script for that account once and makes it available to the widgets inside it. Your own content renders straight away — the provider never withholds it — and each widget appears once the runtime is ready.
77
+ Replace `account-activation-key` with your `activationKey`. The provider loads the Buying Buddy script for that account once and makes it available to the widgets inside it. Your own content renders straight away - the provider never withholds it - and each widget appears once the runtime is ready.
67
78
 
68
79
  ## Examples
69
80
 
@@ -83,7 +94,7 @@ Replace `account-activation-key` with your `activationKey`. The provider loads t
83
94
 
84
95
  > To show listings from the broader MLS instead, add search criteria to the `filter` (below). If the filter contains no other criteria then widgets show the account's own (featured) listings.
85
96
 
86
- **Display selected properties in a grid layout.** All options are expressed as `+`-joined tokens inside a single `filter` string — criteria, sort, and count alike. Use `FIELD()` for a field that accepts several values:
97
+ **Display selected properties in a grid layout.** All options are expressed as `+`-joined tokens inside a single `filter` string: criteria, sort, and count alike. Use `FIELD()` for a field that accepts several values:
87
98
 
88
99
  ```jsx
89
100
  {/* 6 listings over $300k, priced high-to-low */}
@@ -116,7 +127,7 @@ Replace `account-activation-key` with your `activationKey`. The provider loads t
116
127
 
117
128
  ### Next.js
118
129
 
119
- The provider runs entirely in the browser (it loads a script and reads `window`), so the file that renders it must be a **client component**. In the App Router, add the `"use client"` directive at the top of the file — it tells Next.js to run this component in the browser rather than only on the server.
130
+ The provider runs entirely in the browser (it loads a script and reads `window`), so the file that renders it must be a **client component**. In the App Router, add the `"use client"` directive at the top of the file. It tells Next.js to run this component in the browser rather than only on the server.
120
131
 
121
132
  In `app/page.tsx`:
122
133
 
@@ -134,17 +145,17 @@ export default function Page() {
134
145
  }
135
146
  ```
136
147
 
137
- Because the widgets are client-only, their listing content is **not server-rendered** — keep that in mind if SEO of the listings themselves matters to you.
148
+ Because the widgets are client-only, their listing content is **not server-rendered**, so keep that in mind if SEO of the listings themselves matters to you.
138
149
 
139
150
  ### Framer
140
151
 
141
- A standalone, single-file widget for the [Framer](https://www.framer.com) website builder lives at [`framer/BuyingBuddyWidget.tsx`](framer/BuyingBuddyWidget.tsx). It bundles the script loading and adds Framer property controls (activation key, widget type, filter), so you configure everything from Framer's design panel — no React code required.
152
+ A standalone, single-file widget for the [Framer](https://www.framer.com) website builder lives at [`framer/BuyingBuddyWidget.tsx`](framer/BuyingBuddyWidget.tsx). It bundles the script loading and adds Framer property controls (activation key, widget type, filter), so you configure everything from Framer's design panel - no React code required.
142
153
 
143
154
  1. Open [`framer/BuyingBuddyWidget.tsx`](framer/BuyingBuddyWidget.tsx) and copy its entire contents.
144
155
  2. In Framer, go to **Assets → Code → +** and paste it in.
145
156
  3. Drag the component onto your canvas and set your **activation key** in the property panel.
146
157
 
147
- You can also get it pre-filled with your own activation key from your Buying Buddy account dashboard, under **Widgets → Plugin Installation and Setup**.
158
+ You can also get it pre-filled with your own activation key from your Buying Buddy account dashboard, under **Widgets → Installation and Setup**.
148
159
 
149
160
  ## API
150
161
 
@@ -154,8 +165,9 @@ Loads the Buying Buddy runtime for an account and makes it available to the widg
154
165
 
155
166
  | Prop | Type | Default | Description |
156
167
  |------|------|---------|-------------|
157
- | `activationKey` | `string` | — | **Required.** Your Buying Buddy account activation key. |
158
- | `fallback` | `ReactNode` | — | **Deprecated, no-op since 0.3.2.** Accepted and ignored; safe to delete. The provider no longer withholds `children`, so there is no loading state for it to render in. |
168
+ | `activationKey` | `string` | - | **Required.** Your Buying Buddy account activation key. |
169
+ | `seo` | `boolean` | `false` | Declares that every Buying Buddy widget on this page is server-rendered, so the runtime adopts that markup instead of fetching its own. Set it only on pages that use [Server rendering](#server-rendering); it applies to the whole page. |
170
+ | `fallback` | `ReactNode` | - | **Deprecated, no-op since 0.3.2.** Accepted and ignored; safe to delete. The provider no longer withholds `children`, so there is no loading state for it to render in. |
159
171
 
160
172
  ### `<BuyingBuddyWidget>`
161
173
 
@@ -163,7 +175,7 @@ Renders a single widget. Must be a descendant of `<BuyingBuddyProvider>`.
163
175
 
164
176
  | Prop | Type | Description |
165
177
  |------|------|-------------|
166
- | `type` | `BuyingBuddyWidgetType` | **Required.** Widget to render — e.g. `"FeaturedGallery"`, `"SearchForm"`, `"SearchResults"`, `"InteractiveMap"`, `"SearchDetails"`. |
178
+ | `type` | `BuyingBuddyWidgetType` | **Required.** Widget to render, e.g. `"FeaturedGallery"`, `"SearchForm"`, `"SearchResults"`, `"InteractiveMap"`, `"SearchDetails"`. |
167
179
  | `filter` | `string` | Property filter as `+`-joined tokens, e.g. `"city:Denver+FIELD(property_beds:3,4,5)+order:price desc+limit:9"`. |
168
180
  | `style` | `React.CSSProperties` | Inline styles applied directly to the `<bb-widget>` element. A `height` here sizes the widget (e.g. for `InteractiveMap` / `SearchResults`). |
169
181
 
@@ -182,22 +194,219 @@ import type {
182
194
  } from "@buyingbuddy/react";
183
195
  ```
184
196
 
197
+ ## Server rendering
198
+
199
+ `<BuyingBuddyWidget>` renders in the browser, which means the listing content is not in
200
+ the HTML your server sends. Search engines and link previews that do not run JavaScript see
201
+ an empty element.
202
+
203
+ `@buyingbuddy/react/server` fixes that for most widgets. It fetches the widget's HTML on
204
+ your server and puts it in the page, and the Buying Buddy runtime then adopts that markup
205
+ instead of fetching its own.
206
+
207
+ ```tsx
208
+ // app/team/page.tsx - a Next.js Server Component
209
+ import { headers } from "next/headers";
210
+ import { BuyingBuddyServerWidget } from "@buyingbuddy/react/server";
211
+
212
+ export default async function TeamPage() {
213
+ const ip = (await headers()).get("x-forwarded-for")?.split(",")[0];
214
+
215
+ return (
216
+ <BuyingBuddyServerWidget
217
+ type="OfficeRoster"
218
+ activationKey={process.env.BUYING_BUDDY_KEY!}
219
+ domain="www.example.com"
220
+ visitor={{ ip }}
221
+ />
222
+ );
223
+ }
224
+ ```
225
+
226
+ Your provider has to opt the page in:
227
+
228
+ ```tsx
229
+ // app/layout.tsx
230
+ <BuyingBuddyProvider activationKey={process.env.NEXT_PUBLIC_BUYING_BUDDY_KEY!} seo>
231
+ {children}
232
+ </BuyingBuddyProvider>
233
+ ```
234
+
235
+ The provider is still required. It loads the runtime that makes the widget interactive;
236
+ the server import only supplies the markup.
237
+
238
+ ### `seo` applies to the whole page
239
+
240
+ `seo` tells the runtime that every Buying Buddy widget on the page is already rendered into
241
+ its mount. It is a single page-level setting, not a per-widget one, so **a page cannot mix
242
+ server-rendered and browser-rendered Buying Buddy widgets**:
243
+
244
+ | | `seo` set | `seo` not set |
245
+ | --- | --- | --- |
246
+ | widget server-rendered | correct | the browser fetches and replaces markup that was already there |
247
+ | widget not server-rendered | the widget renders blank | correct |
248
+
249
+ Both wrong combinations log a console warning naming the widgets involved, so a mixed page
250
+ tells you rather than just looking broken. Pick one approach per page.
251
+
252
+ Server-rendered mounts carry a `data-bb-ssr` attribute, which is how that check tells them
253
+ from client-rendered ones. It is also a quick way to confirm, in view-source or devtools,
254
+ that a page is server-rendering what you think it is.
255
+
256
+ ### Which widgets
257
+
258
+ ```
259
+ Brokers FeaturedGallery ListingShowcase MarketStats SearchDetails
260
+ Calculator FeaturedList LoginPanel OfficeRoster SearchForm
261
+ Communities LcForm MarketReport QuickSearch
262
+ ```
263
+
264
+ Anything else throws `unsupported_widget`. The search and map widgets - `ListingResults`,
265
+ `SearchResults`, `ResultsMap`, `OpenMap`, `InteractiveMap` - always load live from Buying
266
+ Buddy even on an `seo` page, because their results depend on the visitor's own search, so
267
+ there is nothing useful to prerender. `Disclaimer` has no server-rendered form at all.
268
+ Render those with `<BuyingBuddyWidget>`, on their own pages.
269
+
270
+ ### Pass the visitor through
271
+
272
+ `visitor` is how your visitors keep their own rate limit. A server render makes every
273
+ request come from your server, so without it everyone browsing your site shares one
274
+ allowance; with it, each visitor gets their own and your server gets a much larger one.
275
+
276
+ ```tsx
277
+ visitor={{
278
+ ip: (await headers()).get("x-forwarded-for")?.split(",")[0],
279
+ mbbid: (await cookies()).get("mbb-mbbid")?.value,
280
+ lacid: (await cookies()).get("mbb-lacid")?.value,
281
+ }}
282
+ ```
283
+
284
+ `mbbid` identifies the visitor across requests. This import cannot set the cookie - it has
285
+ no response to set it on - so mint one with `createVisitorId()` and store it yourself.
286
+ Leave `visitor` off entirely for a render with no visitor, such as a build-time page or a
287
+ scheduled job: sending your own server's address as the visitor is worse than sending
288
+ nothing.
289
+
290
+ ### Page metadata
291
+
292
+ The render returns the title, description and canonical URL Buying Buddy resolved for the
293
+ page, which is most of the SEO value for a details page:
294
+
295
+ ```tsx
296
+ import { renderWidget } from "@buyingbuddy/react/server";
297
+
298
+ export async function generateMetadata({ params }) {
299
+ const { meta } = await renderWidget({
300
+ type: "SearchDetails",
301
+ activationKey: process.env.BUYING_BUDDY_KEY!,
302
+ domain: "www.example.com",
303
+ propertyId: params.id,
304
+ });
305
+
306
+ return {
307
+ title: meta.title,
308
+ description: meta.description,
309
+ alternates: { canonical: meta.canonical },
310
+ };
311
+ }
312
+ ```
313
+
314
+ ### Without a React server
315
+
316
+ `renderWidget()` is a plain async function and does not need React on the server. Use it
317
+ from Express, a Remix loader, `getServerSideProps`, or anywhere else, and build the mount
318
+ yourself:
319
+
320
+ ```js
321
+ import { renderWidget } from "@buyingbuddy/react/server";
322
+
323
+ const { html, filterString } = await renderWidget({
324
+ type: "FeaturedGallery",
325
+ activationKey: process.env.BUYING_BUDDY_KEY,
326
+ domain: "www.example.com",
327
+ filter: "limit:12",
328
+ visitor: { ip: req.ip },
329
+ });
330
+
331
+ res.send(`<bb-widget data-type="FeaturedGallery" data-filter="${filterString}">${html}</bb-widget>`);
332
+ ```
333
+
334
+ Use `data-filter` from the result, not the filter you asked for. Buying Buddy resolves
335
+ saved-search references into real criteria, and the mount has to carry the resolved value
336
+ or the widget loses them when it takes over in the browser.
337
+
338
+ `widgetMountProps()` returns these attributes ready to spread onto the element, including
339
+ the `data-bb-ssr` marker, so prefer it over hand-writing the tag where you can.
340
+
341
+ ### Errors
342
+
343
+ A render that does not produce HTML throws `BuyingBuddyError` with a `code` you can branch
344
+ on - `domain_not_authorized`, `invalid_account`, `rate_limited`, `timeout`, `network`,
345
+ `unsupported_widget`, `invalid_request`, `invalid_response`, `render_refused`. Nothing is
346
+ swallowed, because an empty widget looks identical to a working one with no results.
347
+
348
+ ```tsx
349
+ import { renderWidget, isBuyingBuddyError } from "@buyingbuddy/react/server";
350
+
351
+ try {
352
+ const { html } = await renderWidget({ /* ... */ });
353
+ } catch (e) {
354
+ if (isBuyingBuddyError(e) && e.code === "domain_not_authorized") {
355
+ console.error(e.serverHtml); // Buying Buddy's own explanation, with the fix
356
+ }
357
+ throw e;
358
+ }
359
+ ```
360
+
361
+ **Do not cache a failed render.** Requests time out after 3 seconds by default -
362
+ configurable with `timeoutMs` - and under `seo` a missing render shows as a blank space.
363
+ If that gets written into a page cache it stays blank until the cache expires, so let the
364
+ error reach your error boundary, or revalidate immediately, rather than returning an empty
365
+ page.
366
+
367
+ ### Server-only
368
+
369
+ This import must not reach the browser, and it is wired to fail loudly if it does. Your
370
+ bundler resolves it to a stub that throws, so a client-side import breaks with a message
371
+ naming the mistake instead of silently shipping server-shaped code to visitors.
372
+
373
+ To be precise about when: the stub throws when the module is **evaluated**, not when your
374
+ project is built. On the Next.js App Router that means the server render succeeds and the
375
+ page then fails in the browser during hydration. If you would rather catch it at compile
376
+ time, add `import "server-only"` in your own file - that package's check runs in the RSC
377
+ compiler.
378
+
379
+ One thing to know if you run tests: a test runner configured with a browser-like resolution
380
+ (jsdom with `browser` in its resolve conditions) can pick the stub too, and the import will
381
+ throw in your test rather than in a browser. Point the runner at `node` conditions for suites
382
+ that exercise server rendering.
383
+
384
+ ### Also worth knowing
385
+
386
+ - **The HTML is not standalone.** A server-rendered widget's text content is all there,
387
+ which is the SEO payload, but interactive parts - maps especially - are custom elements
388
+ that need the runtime. Keep the provider on the page.
389
+ - **`domain` is required and is not detected.** A server render has no hostname of its own,
390
+ and Buying Buddy checks this value against the domains authorized on your account. Use
391
+ your site's public hostname, not `localhost`.
392
+ - **The activation key is not a secret.** It is the same value as in any browser embed. Use
393
+ `process.env` for convenience, not to protect it.
394
+
185
395
  ## Caveats & limitations
186
396
 
187
- - **One account per page.** The Buying Buddy script installs a single global, so a page is expected to use one `activationKey`. Rendering two providers with different activation keys on the same page is not supported.
188
- - **Client-side only.** Widgets render in the browser after the script loads — nothing is server-rendered. There's no SSR/streaming output, so the listing content isn't in the initial HTML (relevant for SEO).
397
+ - **One account per page.** The Buying Buddy script installs a single global, so a page is expected to use one `activationKey`. Rendering two providers with different activation keys on the same page is not supported. The second provider detects this, logs a console error naming both keys, and sets `error` on its own context; its widgets do not render. The first provider's widgets are unaffected.
398
+ - **`<BuyingBuddyWidget>` renders in the browser.** It mounts after the script loads, so its listing content is not in the initial HTML. If you need the content server-rendered for SEO, use [Server rendering](#server-rendering) instead - it is a separate import, and the two cannot be mixed on one page.
189
399
  - **Changing a prop rebuilds the widget.** Changing `type` or `filter` tears down and recreates the underlying `<bb-widget>`, losing in-widget state (map position, scroll, form input).
190
- - **The script persists after unmount.** Unmounting the provider does not remove the script or reset the global — remounting reuses the already-loaded runtime. This is intentional.
191
- - **A script load failure degrades quietly.** If the runtime script fails to load — CDN outage, ad blocker, CSP rule, corporate proxy, offline — your application renders exactly as it otherwise would and the Buying Buddy widgets are simply absent. The provider renders nothing of its own over your page. The failure is logged to the console once, and is readable as `error` from `useBuyingBuddy()` if you want to say something about it yourself:
400
+ - **The script persists after unmount.** Unmounting the provider does not remove the script or reset the global - remounting reuses the already-loaded runtime. This is intentional.
401
+ - **A script load failure degrades quietly.** If the runtime script fails to load (CDN outage, ad blocker, CSP rule, corporate proxy, offline), your application renders exactly as it otherwise would and the Buying Buddy widgets are simply absent. The provider renders nothing of its own over your page. The failure is logged to the console once, and is readable as `error` from `useBuyingBuddy()` if you want to say something about it yourself:
192
402
 
193
403
  ```tsx
194
404
  const { error } = useBuyingBuddy();
195
405
  if (error) return <p>Property search is temporarily unavailable.</p>;
196
406
  ```
197
407
 
198
- Note this covers script load failure only — an unauthorized domain loads fine but renders empty widgets (see Prerequisites).
408
+ Note this covers script load failure only - an unauthorized domain loads fine but renders empty widgets (see Prerequisites).
199
409
  - **ESM-only.** This package ships as ES modules only (no CommonJS build). Use it in a project with ESM/bundler support.
200
- - **Pre-release.** This package is `0.x` — the API may change.
201
410
 
202
411
  ## Development
203
412
 
@@ -41,5 +41,5 @@ export declare function __resetBundleStateForTests(): void;
41
41
  * </BuyingBuddyProvider>
42
42
  * ```
43
43
  */
44
- export declare function BuyingBuddyProvider({ activationKey, domain, apiBaseUrl, children, }: BuyingBuddyProviderProps): import("react").JSX.Element;
44
+ export declare function BuyingBuddyProvider({ activationKey, domain, apiBaseUrl, seo, children, }: BuyingBuddyProviderProps): import("react").JSX.Element;
45
45
  //# sourceMappingURL=BuyingBuddyProvider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"BuyingBuddyProvider.d.ts","sourceRoot":"","sources":["../src/BuyingBuddyProvider.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAKjF;;;GAGG;AACH,wBAAgB,cAAc,IAAI,uBAAuB,CAQxD;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,GAAG,CAAC,EAAE;YACJ,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;YAC7B,UAAU,EAAE,MAAM,CAAC;YACnB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;SACxB,CAAC;KACH;CACF;AA0DD;;;;;;;;;;;;GAYG;AACH,wBAAgB,0BAA0B,IAAI,IAAI,CAGjD;AA8GD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,mBAAmB,CAAC,EAClC,aAAa,EACb,MAAuB,EACvB,UAAU,EACV,QAAQ,GAKT,EAAE,wBAAwB,+BA6G1B"}
1
+ {"version":3,"file":"BuyingBuddyProvider.d.ts","sourceRoot":"","sources":["../src/BuyingBuddyProvider.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAKjF;;;GAGG;AACH,wBAAgB,cAAc,IAAI,uBAAuB,CAQxD;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,GAAG,CAAC,EAAE;YACJ,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;YAC7B,UAAU,EAAE,MAAM,CAAC;YACnB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;SACxB,CAAC;KACH;CACF;AAmED;;;;;;;;;;;;GAYG;AACH,wBAAgB,0BAA0B,IAAI,IAAI,CAQjD;AAyQD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,mBAAmB,CAAC,EAClC,aAAa,EACb,MAAuB,EACvB,UAAU,EACV,GAAW,EACX,QAAQ,GAKT,EAAE,wBAAwB,+BAyK1B"}