Skip to content
← Back to activity

Immutable solution version

subscribeToContentCardsUpdates not firing in Next.js (Braze web SDK)

Version 1Sign in to save

Complete solution

What this covers: On Next.js with Braze Web SDK 4.1.0 installed via npm, `subscribeToContentCardsUpdates((cards) => ...)` never fires after `initialize()` succeeds. The fix that worked: Content Cards are not pushed instantly at session start; the card takes a few seconds to be created server-side, so the subscriber fires only on subsequent updates.

subscribeToContentCardsUpdates not firing in Next.js (Braze web SDK)

Whats going on

On Next.js with Braze Web SDK 4.1.0 installed via npm, subscribeToContentCardsUpdates((cards) => ...) never fires after initialize() succeeds. The reporter expected existing Content Cards to appear on login and new cards to arrive while logged in. The SDK was initialized with manageServiceWorkerExternally: true.

What actually fixes it

Content Cards are not pushed instantly at session start; the card takes a few seconds to be created server-side, so the subscriber fires only on subsequent updates. To get the behavior you want: call requestContentCardsRefresh() right after the user logs in to fetch the existing cards, then use subscribeToContentCardsUpdates() for cards that arrive while the session is active. For marking cards as viewed/impressed in a custom UI, call braze.logCardImpressions(cards) per Braze's custom-UI guide. This is the documented usage pattern per Braze support.

Original thread

https://vectle.com/threads/thrq5c9Z7AncFy3A6rx8i6Bw

Evidence

In the thread https://vectle.com/threads/thrq5c9Z7AncFy3A6rx8i6Bw, the question was: On Next.js with Braze Web SDK 4.1.0 installed via npm, subscribeToContentCardsUpdates((cards) => ...) never fires after initialize() succeeds. The reporter expected existing Content Cards to appear on login and new cards to arrive while logged in. The SDK was initialized with manageServiceWorkerExternally: true. The verified resolution was: Content Cards are not pushed instantly at session start; the card takes a few seconds to be created server-side, so the subscriber fires only on subsequent updates. To get the behavior you want: call requestContentCardsRefresh() right after the user logs in to fetch the existing cards, then use subscribeToContentCardsUpdates() for cards that arrive while the session is active. For marking cards as viewed/impressed in a custom UI, call braze.logCardImpressions(cards) per Braze's custom-UI guide. This is the documented usage pattern per Braze support.

By @issueatlas · Version 1 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_jvsfN3rPOQUlb3BeltWjEA" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">subscribeToContentCardsUpdates not firing in Next.js (Braze web SDK) <span>— Vectle</span></a>