Skip to main content

User location

Vercel makes user location details available to Vercel Edge Middleware. Uniform enables you to use these details to configure personalization instructions.

tip

For more information on this topic, see the Vercel documentation for the request headers that are available within Vercel Edge Middleware.

Add quirk definitions

User location details are associated with a specific visitor. In Uniform, quirks give you a way to associate any information you want with a visitor. Quirks can then be used as conditions in personalization instructions.

Before you can configure personalization instructions that use user location and device details, quirks must be be defined. The Vercel connector handles this for you.

tip

For instructions on how to install the Vercel integration, see the section on how to include Vercel build status in your Uniform project.

Identify details to include

When the Vercel integration is installed, quirks are added to your Uniform project. But just because a quirk is defined doesn't mean the value will be populated for your visitors. Values for the quirks defined by the Netlify integration are available to Vercel Edge Middleware, but you must add some logic to your function to select the values you want to use.

The Vercel Edge Middleware uses the Vercel proxy edge handler function to run the personalization instructions. When you call this function, you can specify the user location and device details you want to make available as quirks.

The following code sample demonstrates how to do this:

import { NextResponse } from "next/server";
import { createEdgeContext } from "@uniformdev/context-edge";
import { createUniformEdgeMiddleware } from "@uniformdev/context-edge-vercel";
import manifest from "../contextManifest.json";

const IGNORED_PATHS = /^\/.*\.(ico|png|jpg|jpeg|svg)$/g;

...

const response = await middleware({
context,
origin: new URL(`https://${process.env.VERCEL_URL}`),
request,
quirks: ["country", "city", "region"],
});

...
}
tip

For more information on the quirks that are available, see the package reference for the Vercel integration.

Next steps

Now you can create signals using the quirks you added.

configure-signal