Start

Getting Started

Install PassIt, define your first config, load it in Next.js 15, and proxy your first route.

Install

bash
npm install @pajarrahmansyah/passit

For optional Axios support:

bash
npm install axios

Create your config

Create passit.config.ts at your project root.

ts
import { defineConfig } from "@pajarrahmansyah/passit"; export default defineConfig({ baseUrl: "https://api.backend.com", headers: { "x-api-key": process.env.API_KEY, }, });

Load the config

The most route-safe setup is to import your config in the route and use the typed passIt function returned by defineConfig.

ts
// app/api/users/route.ts import passit from "@/passit.config"; import type { NextRequest } from "next/server"; export async function GET(req: NextRequest) { return passit.passIt({ path: "/users", req }); }

This avoids relying on server startup module order.

If you prefer importing package-level passIt, load your config once during server startup. For Next.js 15, create instrumentation.ts at your project root.

ts
export async function register() { await import("./passit.config"); }

Use package-level passIt

ts
import { passIt } from "@pajarrahmansyah/passit"; import type { NextRequest } from "next/server"; export async function GET(req: NextRequest) { return passIt({ path: "/users", req, }); }

Your client calls /api/users. PassIt forwards that request to https://api.backend.com/users.

Pass req when query params, request bodies, or client headers should be forwarded. Omit req only for server-initiated routes that do not depend on client input.