Application activation
Before you start
This section assumes your origin is a web application that is already configured to use Uniform personalization. If you don't have this available, you can use one of our tutorials].
- Next.js
For an application built using Next.js, you only need to add a prop to the Uniform context component.
Add the following npm package to your project:
@uniformdev/context-nextOpen the file that creates the context object (i.e.
const context = new Context({...).About this step
This might be
/pages/_app.js, or it might be a separate file, such as/lib/uniform/uniformContext.js.Add the following import statement:
import { NextCookieTransitionDataStore } from "@uniformdev/context-next";Add the following code:
const context = new Context({
transitionStore: new NextCookieTransitionDataStore({
serverContext: undefined,
}),
...
});Open the file
/pages/_app.js.Find the component
UniformContext.<UniformContext context={context}>
<Layout pageProps={pageProps}>
<Component {...pageProps} />
</Layout>
</UniformContext>Set the prop outputType to
edge:<UniformContext context={context} outputType='edge'>
<Layout pageProps={pageProps}>
<Component {...pageProps} />
</Layout>
</UniformContext>About this step
Setting the output type tells Uniform to include the instructions for personalization in a format that the EdgeWorker can run.
The next time you deploy the application, edge-side personalization will be enabled.