@amplifyup/sdk 0.1.51 → 0.1.53

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.
@@ -829,7 +829,9 @@ var AmplifyUpSDK = class {
829
829
  this.page(url);
830
830
  this.lastTrackedPath = url;
831
831
  this.setupPageEngagement();
832
- this.installHistoryHooks();
832
+ if (!this.isNextJsApp()) {
833
+ this.installHistoryHooks();
834
+ }
833
835
  }
834
836
  }
835
837
  if (this.config?.debug && this.initialized) {
@@ -1082,9 +1084,21 @@ var AmplifyUpSDK = class {
1082
1084
  console.log("[AmplifyUp SDK] Route change page view", path);
1083
1085
  }
1084
1086
  }
1087
+ /** True on Next.js (App or Pages). Do not patch history on these apps. */
1088
+ isNextJsApp() {
1089
+ if (typeof window === "undefined" || typeof document === "undefined") {
1090
+ return false;
1091
+ }
1092
+ const win = window;
1093
+ if (win.next) return true;
1094
+ if (document.getElementById("__next")) return true;
1095
+ if (document.querySelector('script[src*="/_next/"]')) return true;
1096
+ return false;
1097
+ }
1085
1098
  /**
1086
1099
  * Patch history.pushState / replaceState + popstate for non-React SPAs.
1087
- * React/Next apps should also call routeChange from the provider.
1100
+ * Next.js apps use AmplifyUpProvider.routeChange via usePathname instead —
1101
+ * wrapping history breaks App Router <Link> (no RSC request).
1088
1102
  */
1089
1103
  installHistoryHooks() {
1090
1104
  if (typeof window === "undefined" || this.historyHooksInstalled) return;