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