Environment file
dotenv
PBJ_API_KEY=pbj_test_replace_me
PBJ_API_URL=https://api.pbjspace.dev
PBJ_SOLANA_NETWORK=devnet
PBJ_SOLANA_RPC_URL=Never commit local environment files. The SDK does not load dotenv itself; your runtime supplies configuration explicitly.
Node.js usage
ts
import { PBJClient } from "pbjspace";
const pbj = new PBJClient({
apiKey: process.env.PBJ_API_KEY!,
});
const projects = await pbj.projects.list({ limit: 10 });
console.log(projects.data);Next.js server route
ts
// lib/pbj.ts
import 'server-only';
import { PBJClient } from "pbjspace";
export const pbj = new PBJClient({
apiKey: process.env.PBJ_API_KEY!,
});
// app/api/pbj/projects/route.ts
import { pbj } from "@/lib/pbj";
export async function GET() {
// Verify your application's user here.
return Response.json(await pbj.projects.list({ limit: 20 }));
}Security checklist
- Never use
NEXT_PUBLIC_PBJ_API_KEY. - Authorize the current application user before proxying PBJ data.
- Do not share a privileged client across tenants without access checks.
- Use RPC URLs without embedded secrets when forwarded as query values.
- Redact error details and causes before logging them.
- Create a new client when credentials rotate.
