Route Hashing Method

The Route Hashing method determines User Context and saves it as a route hash.

Requirements

  1. This method works only on pages that follow a blob pattern, i.e. products/:slug, and use getStaticProps (i.e., PDP pages).

  2. getStaticPaths must return fallback: 'blocking' . This is required to build page new Test Group combinations live.

Routes without a blob pattern that use getStaticProps must be converted to use getServerSideProps. i.e., the home, cart, and search pages.

Why? The Route Hasing Method won’t work on /index because the internal route would be converted to a hashed route, such as /eyJhIjoiYiIsInVybFBhdGgiOiIvIn0.

However, this hashed route doesn’t exist as far as Next.js is concerned and would redirect to a nonexistent page on the site.

Considerations

Pros

  1. Speed. Pages using the method will be cached internally by Next.js. For example, two users in the same Test Group will be redirected directly to the cached page.

Cons

  1. The number of cached pages will grow exponentially based on the number of active Tests and Test Groups per test, per route. For example, a site with 3 Experiments with 3 Test Groups each will have 27 possible Test Group permutations per route.

  2. Additional hosting costs due to additional page builds and caching may occur. Verify build and hosting limits with your hosting provider.