Skip to content

Redirect chains

Reactive Route supports an unlimited number of redirects in CSR and SSR.

In this example, if the user navigates to /4, they will be redirected /4/3/2/1. Intermediate redirects are not reflected in browser history, and chunks for them will not be loaded.

ts
createConfigs({
  one: {
    path: '/1',
    loader: () => import('./pages/one'),
  },
  two: {
    path: '/2',
    loader: () => import('./pages/two'),
    async beforeEnter({ redirect }) {
      return redirect({ name: 'one' });
    },
  },
  three: {
    path: '/3',
    loader: () => import('./pages/three'),
    async beforeEnter({ redirect }) {
      return redirect({ name: 'two' });
    },
  },
  four: {
    path: '/4',
    loader: () => import('./pages/four'),
    async beforeEnter({ redirect }) {
      return redirect({ name: 'three' });
    },
  },
  
  // other Configs
});

No AI participated in the development. MIT License