@remix-run/router 0.0.0-experimental-e1311612e → 0.0.0-experimental-cffa549a1

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/utils.d.ts CHANGED
@@ -500,6 +500,13 @@ export declare const redirect: RedirectFunction;
500
500
  * Defaults to "302 Found".
501
501
  */
502
502
  export declare const redirectDocument: RedirectFunction;
503
+ /**
504
+ * A redirect response that will perform a `history.replaceState` instead of a
505
+ * `history.pushState` for client-side navigation redirects.
506
+ * Sets the status code and the `Location` header.
507
+ * Defaults to "302 Found".
508
+ */
509
+ export declare const replace: RedirectFunction;
503
510
  export type ErrorResponse = {
504
511
  status: number;
505
512
  statusText: string;
package/index.ts CHANGED
@@ -48,6 +48,7 @@ export {
48
48
  normalizePathname,
49
49
  redirect,
50
50
  redirectDocument,
51
+ replace,
51
52
  resolvePath,
52
53
  resolveTo,
53
54
  stripBasename,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remix-run/router",
3
- "version": "0.0.0-experimental-e1311612e",
3
+ "version": "0.0.0-experimental-cffa549a1",
4
4
  "description": "Nested/Data-driven/Framework-agnostic Routing",
5
5
  "keywords": [
6
6
  "remix",
package/router.ts CHANGED
@@ -2683,7 +2683,9 @@ export function createRouter(init: RouterInit): Router {
2683
2683
  pendingNavigationController = null;
2684
2684
 
2685
2685
  let redirectHistoryAction =
2686
- replace === true ? HistoryAction.Replace : HistoryAction.Push;
2686
+ replace === true || redirect.response.headers.has("X-Remix-Replace")
2687
+ ? HistoryAction.Replace
2688
+ : HistoryAction.Push;
2687
2689
 
2688
2690
  // Use the incoming submission if provided, fallback on the active one in
2689
2691
  // state.navigation
package/utils.ts CHANGED
@@ -1619,6 +1619,18 @@ export const redirectDocument: RedirectFunction = (url, init) => {
1619
1619
  return response;
1620
1620
  };
1621
1621
 
1622
+ /**
1623
+ * A redirect response that will perform a `history.replaceState` instead of a
1624
+ * `history.pushState` for client-side navigation redirects.
1625
+ * Sets the status code and the `Location` header.
1626
+ * Defaults to "302 Found".
1627
+ */
1628
+ export const replace: RedirectFunction = (url, init) => {
1629
+ let response = redirect(url, init);
1630
+ response.headers.set("X-Remix-Replace", "true");
1631
+ return response;
1632
+ };
1633
+
1622
1634
  export type ErrorResponse = {
1623
1635
  status: number;
1624
1636
  statusText: string;