Choose a setup

Developer preview

This feature is in developer preview. Use with caution as it may change unexpectedly. For more information, contact us.

The SDK supports different setups. Answer the three questions on this page to select the setup for your app. If you do not know, use the recommended answer of each question. You can change the setup later.

QuestionRecommended answer
Which routes render Uniform content?The [code] route
Who chooses the personalization variants?The edge (edge mode)
How does Next.js cache the pages?ISR, with pages rendered on their first visit
SetupUse it whenRefer to
The [code] route (recommended)Authors build the pages in Uniform, and the project map has the URLs. One route file renders all pages.Tutorial
Ordinary routesYou need your own route files, for example app/blog/[slug]/page.tsx, for each page type. The page resolves the composition from its path.Use ordinary Next.js routes
Hybrid pagesThe pages are hard-coded in Next.js already. Uniform manages only some regions of each page, for example banners.Hybrid pages

With ordinary routes and hybrid pages, each project map node that has a composition must have a Next.js route. Without a route, the path gives a 404, also in Canvas preview.

Lite modeEdge mode (recommended)
MiddlewareuniformMiddlewarevercelUniformEdgeMiddleware, or uniformEdgeMiddleware on other hosts
What the visitor sees firstThe default variants. Then the browser changes them.The variants of the visitor
Extra packagesNone@vercel/functions on Vercel
Extra costNoneOne more request for each page load, and CPU time for the transform
Use it whenThe site has no personalizations or tests above the fold, or the change after hydration is acceptable.Personalizations or tests are visible on the first screen.

Visibility rules run in the browser in the two modes. Refer to Personalization and A/B tests and Edge mode execution.

HostMiddlewareManifestCache expiry
VercelvercelUniformEdgeMiddleware()Loaded at runtime, kept in the Vercel runtime cacheonRevalidateTags: expireVercelRuntimeCacheTags
Other hostsuniformEdgeMiddleware({ manifest })A JSON file from the build, or createCachedManifestProvider with your cacheThe next build, or your cache

Refer to Set up edge mode on other hosts.

StrategySetupUse it when
ISR, rendered on the first visit (recommended)generateStaticParams returns [].Most sites. The build is fast, and only the first visitor of each page waits for the render.
ISR, with prerendered pagesgenerateStaticParams returns createUniformStaticParams({ paths }).The first visit of the most important pages must be fast.
Cache ComponentscacheComponents: true, and the resolvers from @uniformdev/next-app-router/cache.Your app uses Cache Components already, or parts of the page are dynamic.

In all strategies, Uniform webhooks revalidate the cached pages when authors publish. Refer to Static generation (ISR) and Caching.

warning

With Cache Components, Next.js does not accept an empty generateStaticParams. Return at least one code.

AppRoutesVariantsCache
Marketing site with campaign personalization on the home page[code] routeEdge modeISR, prerender the home page
Documentation site without personalization[code] routeLite modeISR on the first visit
Commerce site with product pages in Next.js and banners from UniformHybrid pagesEdge modeISR on the first visit
Blog with its own route filesOrdinary routesLite modeISR on the first visit