Install the yeetpost package:
Set your API key as an environment variable in .env.local. Keep it out of any name that starts with NEXT_PUBLIC_, because those are inlined into the browser bundle:
YEETPOST_API_KEY=<your-api-key>
Send the post from a route handler, a server action or a scheduled job, never from a client component:
// app/api/announce/route.ts
import { yeetpost } from "yeetpost";
export async function POST(request: Request) {
const { text } = await request.json();
await yeetpost({
connection: "<your-connection-slug>",
text,
});
return Response.json({ ok: true });
}
Deploying on Vercel? Add YEETPOST_API_KEY under Project Settings, Environment Variables, so the server build has it as well as your machine.