Fidro + Next.js Integration
Block disposable emails in Next.js with server-side validation. Follow this guide to add email validation and IP intelligence in minutes.
Overview
To integrate Fidro with Next.js, use the built-in fetch API in a Server Action or API Route to send a POST request to the Fidro API with the user's email and IP address. Fidro returns email validation, disposable email detection, IP intelligence, and a fraud risk score in one API call. No SDK or extra npm packages are needed — Next.js's built-in fetch works perfectly for both App Router and Pages Router setups.
Fidro is a fraud detection API that combines email validation, IP intelligence, geolocation analysis, and Stripe chargeback prevention in a single API call. It returns a risk score with a clear recommendation — allow, review, or block — so you can stop fraud without building your own scoring logic.
1. Install Dependencies
# Uses built-in fetch — no extra packages needed
You will also need a Fidro API key. Sign up for free to get one.
2. Email Validation
Send a POST request to Fidro's /v1/validate endpoint with the user's email address and optional IP. Fidro validates the email, checks for disposable domains, analyzes the IP for VPN/proxy/Tor usage, and returns a risk score with a clear recommendation — allow, review, or block.
// app/api/validate/route.ts (App Router)
import { NextRequest, NextResponse } from "next/server";
export async function POST(request: NextRequest) {
const { email } = await request.json();
const ip = request.headers.get("x-forwarded-for") || "127.0.0.1";
const response = await fetch("https://api.fidro.io/v1/validate", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.FIDRO_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({ email, ip }),
});
if (!response.ok) {
return NextResponse.json(
{ error: "Validation failed" },
{ status: response.status }
);
}
const result = await response.json();
if (result.data.recommendation === "refund") {
return NextResponse.json(
{ error: "This email has been flagged as high risk" },
{ status: 403 }
);
}
return NextResponse.json({
risk_score: result.data.risk_score,
recommendation: result.data.recommendation,
});
}
// ----- Server Action example -----
// app/actions/validate-email.ts
"use server";
export async function validateEmail(email: string) {
const response = await fetch("https://api.fidro.io/v1/validate", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.FIDRO_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({ email, ip: "8.8.8.8" }),
});
if (!response.ok) {
throw new Error("Validation failed");
}
return response.json();
}
3. IP Lookup
Send a POST request to Fidro's /v1/ip-lookup endpoint with an IP address. Fidro returns geolocation data (country, city, ISP), VPN and proxy detection, Tor exit node identification, and threat intelligence — all in a single API call.
// app/api/ip-lookup/route.ts (App Router)
import { NextRequest, NextResponse } from "next/server";
export async function GET(request: NextRequest) {
const ip = request.headers.get("x-forwarded-for") || "127.0.0.1";
const response = await fetch("https://api.fidro.io/v1/ip-lookup", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.FIDRO_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({ ip }),
});
if (!response.ok) {
return NextResponse.json(
{ error: "IP lookup failed" },
{ status: response.status }
);
}
const result = await response.json();
return NextResponse.json({
country: result.data.country,
is_vpn: result.data.is_vpn,
});
}
Test the IP lookup response format with our free IP checker tool before integrating.
Next steps
Explore the full API reference, try the free email checker, or see how Fidro compares to other solutions.
Frequently Asked Questions
How do I add fraud detection to Next.js?
Does Fidro have a Next.js SDK?
Is Fidro free to use with Next.js?
Start catching bad signups in the next 5 minutes
Create your account, grab your API key, and send your first request. Free plan with 200 validations/month. No credit card. Cancel anytime.
Get Started Free