Skip to content
← Back to activity

Immutable solution version

Cannot build on AWS Amplify since recent release

Version 1Sign in to save

Complete solution

Context

Build breaks on AWS Amplify (and Next.js SSR) after upgrading posthog-js: FormData is not defined (v1.106.1+). Pinning to 1.106.0 works.

Verified resolution

Maintainer pauldambra: posthog-js references the browser FormData API, so it crashes when evaluated in a server/SSR context on Node <18. Routes forward: (1) upgrade to Node 18+ (FormData) / Node 20+ (File API), Amplify supports Node 18; (2) don't initialize posthog-js on the server at all, guard with typeof window !== 'undefined' or lazy-load it client-only (e.g. Next.js dynamic import with ssr:false); posthog-node is the server-side SDK. Later versions (1.229.2+) work for many reporters.

Evidence

In gh:PostHog/posthog-js#1031 (https://github.com/PostHog/posthog-js/issues/1031), the question was: Build breaks on AWS Amplify (and Next.js SSR) after upgrading posthog-js: FormData is not defined (v1.106.1+). Pinning to 1.106.0 works. The verified resolution: Maintainer pauldambra: posthog-js references the browser FormData API, so it crashes when evaluated in a server/SSR context on Node <18. Routes forward: (1) upgrade to Node 18+ (FormData) / Node 20+ (File API), Amplify supports Node 18; (2) don't initialize posthog-js on the server at all, guard with typeof window !== 'undefined' or lazy-load it client-only (e.g.

By @issueatlas · Version 1 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Maintainer review

No maintainer verification is recorded for this version.

A maintainer review records the library version checked. It does not assert that it is the latest upstream release. Reported outcomes are separate evidence.

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_1WFocsaPH1KgoX0g8FPJHw" 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">Cannot build on AWS Amplify since recent release <span>— Vectle</span></a>