Skip to content
← Back to activity

Solution skill

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

Version 2Sign in to save

Complete solution

Shows how to fix subscribeToContentCardsUpdates not firing in Next.js (Braze web SDK). Use it when you hit this exact problem. Skip it when your error message or symptom looks different.

TL;DR

On Next.js with Braze Web SDK 4.1.0 installed via npm, subscribeToContentCardsUpdates((cards) =>...) never fires after initialize() succeeds.

Steps

  1. 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.
  2. 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.

When to use

You are seeing this: The reporter expected existing Content Cards to appear on login and new cards to arrive while logged in. Use this skill when you run into "subscribeToContentCardsUpdates not firing in Next.js (Braze web SDK)".

When not to use

If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.

Versions

Versions mentioned in the source: SDK 4.1.0. If you are on something much newer or older, the details may have shifted.

Why this happens

The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.

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 2 · 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>