Skip to main content

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].

For an application built using Next.js, you only need to add a prop to the Uniform context component.

  1. Add the following npm package to your project:

    @uniformdev/context-next
  2. Open 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.

  3. Add the following import statement:

    import { NextCookieTransitionDataStore } from "@uniformdev/context-next";
  4. Add the following code:

    const context = new Context({
    transitionStore: new NextCookieTransitionDataStore({
    serverContext: undefined,
    }),
    ...
    });
  5. Open the file /pages/_app.js.

  6. Find the component UniformContext.

    <UniformContext context={context}>
    <Layout pageProps={pageProps}>
    <Component {...pageProps} />
    </Layout>
    </UniformContext>
  7. 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.

  8. The next time you deploy the application, edge-side personalization will be enabled.