github MRVDH/picnic-api v4.10.0

4 hours ago

⚠️ Breaking change

The default x-picnic-agent is now 30100;1.246.1-15599; (was 1.236.1-15553). For this app version Picnic serves a few pages as a React Server Components payload (text/x-component) instead of a Fusion page. app.getPage now throws an UnexpectedPageFormatError for those pages, where it used to return JSON.

Pages affected so far (out of 95 I tested):

  • category-tree-root (search tab shortcuts and categories)
  • profile-root
  • promo-group-deep-dive?promo_group_id=<id>

If you call getPage on one of these, switch to the new app.getRscPage, or catch the error and fall back:

try {
  const page = await client.app.getPage(pageId);
} catch (error) {
  if (!PicnicClient.isUnexpectedPageFormatError(error)) throw error;
  const rscPage = await client.app.getRscPage(error.pageId);
}

To keep the old behaviour for now, pass the previous agent: new PicnicClient({ agent: "30100;1.236.1-15553;" }). I'd expect Picnic to move more pages over time, so that's a temporary workaround.

New

  • app.getRscPage(pageId): fetches a page served as RSC and parses it into rows (JSON rows by row id) and modules (client component references). The page data is in the props of the React elements.
  • PicnicClient.UnexpectedPageFormatError and PicnicClient.isUnexpectedPageFormatError.
  • sendRequest returns text/x-component responses as raw text instead of failing on JSON.parse.

All other read-only routes that send the agent header return the same data for both agent versions.

What's Changed

  • feat(app): support pages served as React Server Components by @MRVDH in #57

Full Changelog: v4.9.0...v4.10.0

Don't miss a new picnic-api release

NewReleases is sending notifications on new releases.