Trip Checker Template
- Next.js
- TypeScript
Check whether a passport needs a visa for a destination, and whether it stays valid long enough for the trip.
A Next.js app that checks a trip before you book it. Pick a passport and a destination to see whether you need a visa, an ETA or an eVisa, how long you can stay, and the official site to apply on. Add your travel dates and passport expiry, and it checks whether your passport is valid for long enough. Use it on a travel site, in a booking flow, or as a tool for a travel agency.

What it does
- Visa answer at a glance
- A boarding-pass result in green, amber or red: no visa, an ETA, eVisa or visa on arrival, or a visa to arrange first.
- Passport validity check
- Shows the destination’s validity rule, and with your dates, the exact day your passport must be valid until and whether it passes.
- Official application links
- For ETAs and eVisas, a button to the government’s own application site, never an agent.
- Health and safety notes
- Blank pages, yellow fever certificate rules and current UK and US travel advice, all on the same ticket.
- Keeps your key private
- The page only calls your own API route, which checks the input, caches answers for an hour and limits each visitor to 10 lookups a minute.
How it works
The API route: it checks the codes and dates, then calls Visa Requirements and Travel Entry Requirements together.
export async function GET(request: Request) {
const params = new URL(request.url).searchParams;
const passport = str(params.get('passport'), 2).toUpperCase();
const destination = str(params.get('destination'), 2).toUpperCase();
const arrival = str(params.get('arrival'), 10);
const expiry = str(params.get('expiry'), 10);
if (!CODE.test(passport) || !CODE.test(destination)) return fail('Pick a passport and a destination');
if (passport === destination) return fail('Pick a destination other than your own country');
if ((arrival && !DATE.test(arrival)) || (expiry && !DATE.test(expiry))) return fail('Dates must be YYYY-MM-DD');
const key = `trip:${passport}:${destination}:${arrival}:${expiry}`;
const hit = fromCache(key, TTL_MS);
if (hit) return Response.json(hit);
const blocked = guard(request);
if (blocked) return blocked;
return respond(async () => {
const entryQuery: Record<string, string> = { destination };
if (arrival) entryQuery.arrivalDate = arrival;
if (expiry) entryQuery.passportExpiry = expiry;
// Two calls in parallel: can I go (Visa Requirements), and what does my passport need (Entry Requirements).
// Entry rules aren't published for every destination, so a missing answer there still shows the visa.
const [visa, entry] = await Promise.all([
callApi('visarequirements', { query: { passport, destination } }),
callApi('entryrequirements', { query: entryQuery }).catch(() => null)
]);
const data = { visa, entry };
toCache(key, data);
return data;
});
}Deploy it
- Get a free API key
The free plan includes 200 credits a month, no card needed. Create your key.
- Deploy it
Click Deploy to Vercel. Vercel copies the repo to your GitHub account and asks for
APIVERVE_API_KEY: paste your key there. - Open your app
Vercel builds it and gives you a live URL, usually in about a minute. Every push to the repo redeploys it.
Try the Visa Requirements API — the call this template makes
No key required to try it. Get a key to use it in your app.
{
"status": "ok",
"error": null,
"data": {
"passport": "US",
"passportName": "United States",
"destination": "JP",
"destinationName": "Japan",
"requirement": "visa_free",
"requirementLabel": "Visa not required",
"visaRequiredInAdvance": false,
"allowedStayDays": 90,
"allowedStay": "90 days",
"options": [
"visa_free"
],
"onlineApplication": null,
"updatedAt": "2026-10-19T03:33:20.529Z"
}
}