Migrate from MVC to Next.js
Overview
You can gradually migrate your Web Forms and MVC pages to Next.js using a hybrid development approach - running all technologies in the same project. This is possible, because with the setup described in this article, the renderer do not limit you to creating and editing only Next.js pages.
To have a seamless experience when using the standalone Renderer application together with Sitefinity CMS rendering (running Web Forms or MVC), the Renderer is also working as a proxy with the setup described in this article. It forwards every request it cannot handle to Sitefinity CMS.
NOTE: Rendering ASP.NET Core or Next.js widgets in MVC or Web Forms pages or vice versa is not possible.
Legacy MVC and Web Forms pages handling
If you want to handle legacy MVC and Web Forms pages with Next.js, their URLs must be explicitly specified in one of two places:
- In
middleware.ts
file: there is a variable called whitelistedPaths
which is an array of strings. The URLs of the pages can be placed as separate strings:
const whitelistedPaths: string[] = ['/legacypageurlone', '/legacypageurltwo'];
- In
env.development
file: by modifying the environmental variable SF_WHITELISTED_PATHS
.
For example: SF_WHITELISTED_PATHS="/legacypageurlone,/legacypageurltwo"
.
Legacy MVC and Web Forms home page navigation
If the home page of the site is legacy (MVC/Web Forms) navigation to it can be proxied and not rendered in two ways:
- Navigating directly to the URL: 'www.siteurl/homepage'. This requires the home page to be listed in the
whitelistedPaths
variable.
- Navigating directly to the URL: 'www.siteurl/'. This requires setting
SF_IS_HOME_PAGE_LEGACY="true"
in the env.development
file.