@amplifyup/sdk 0.1.52 → 0.1.54

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/dist/index.mjs CHANGED
@@ -1164,7 +1164,9 @@ var AmplifyUpSDK = class {
1164
1164
  this.page(url);
1165
1165
  this.lastTrackedPath = url;
1166
1166
  this.setupPageEngagement();
1167
- this.installHistoryHooks();
1167
+ if (!this.isNextJsApp()) {
1168
+ this.installHistoryHooks();
1169
+ }
1168
1170
  }
1169
1171
  }
1170
1172
  if (this.config?.debug && this.initialized) {
@@ -1417,9 +1419,21 @@ var AmplifyUpSDK = class {
1417
1419
  console.log("[AmplifyUp SDK] Route change page view", path);
1418
1420
  }
1419
1421
  }
1422
+ /** True on Next.js (App or Pages). Do not patch history on these apps. */
1423
+ isNextJsApp() {
1424
+ if (typeof window === "undefined" || typeof document === "undefined") {
1425
+ return false;
1426
+ }
1427
+ const win = window;
1428
+ if (win.next) return true;
1429
+ if (document.getElementById("__next")) return true;
1430
+ if (document.querySelector('script[src*="/_next/"]')) return true;
1431
+ return false;
1432
+ }
1420
1433
  /**
1421
1434
  * Patch history.pushState / replaceState + popstate for non-React SPAs.
1422
- * React/Next apps should also call routeChange from the provider.
1435
+ * Next.js apps use AmplifyUpProvider.routeChange via usePathname instead —
1436
+ * wrapping history breaks App Router <Link> (no RSC request).
1423
1437
  */
1424
1438
  installHistoryHooks() {
1425
1439
  if (typeof window === "undefined" || this.historyHooksInstalled) return;