Vercel (Next.js)
The DataDome module for Vercel detects bot activity and protects you against it
This module can be installed as a middleware with Vercel's Edge Functions and sends validation requests to the closest regional endpoints. Depending on how the API responds, the module either blocks the request or lets Vercel proceed with the intended backend.
This article will treat both server-side and client-side integrations.
Prerequisites
- The server-side key available in your DataDome dashboard
- The client-side key available in your DataDome dashboard
- Next.js 13+
How to install and configure
Vercel provides an example you can reuse to integrate DataDome inside your Vercel app.
- Copy the
lib
folder from the example to your Vercel app - Update or create your own middleware to call the DataDome middleware (example)
- Integrate DataDome's JavaScript tags inside your pages (example)
- Add a DATADOME_SERVER_SIDE_KEY variable inside Your Vercel Project > Project Settings > Environment Variables with the
server-side
key that you can find in the Management section of your dashboard - Also add a NEXT_PUBLIC_DATADOME_CLIENT_SIDE_KEY variable with the
client-side
key from your dashboard
- Update other settings if needed
- Redeploy your Vercel app
Congratulations! Your website is now protected against bot traffic at the Edge.
Settings
Setting | Description | Default |
---|---|---|
DATADOME_SERVER_SIDE_KEY | Your DataDome server-side key | "" |
NEXT_PUBLIC_DATADOME_CLIENT_SIDE_KEY | Your DataDome client-side key | "" |
DATADOME_TIMEOUT | The timeout limit for requests sent to the DataDome API, in milliseconds | 300 |
DATADOME_URI_REGEX_EXCLUSION | Ignores all matching URIs | Extensions for static assets |
Environment variables for the browser
The DataDome client side key must be available in the browser, for this reason is must match the naming convention defined in the Nextjs documentation and be prefixed by
NEXT_PUBLIC_
.
Updated 2 days ago