Skip to main content
TryRoki has no SDK and no npm package to install. When it publishes an article it sends the finished content to a webhook endpoint you host — a single HTTP POST with a JSON body, authenticated by a shared secret you choose. This guide walks an AI coding agent through wiring that endpoint into a Next.js App Router project and rendering the articles as a blog.

One-prompt setup

Paste this into your AI coding agent (Cursor, Claude Code, v0, Windsurf, …) inside your Next.js project. It has everything the agent needs to do the whole integration.
prompt
The rest of this page is the same integration done by hand, in case you’d rather follow the steps yourself.

What you’re building

A shared secret

An env var both TryRoki and your endpoint know, so you can reject anyone else.

A webhook route

An App Router route handler at /api/tryroki that receives and stores each article.

A blog

/blog and /blog/[slug] pages that render the articles TryRoki sends.

Prerequisites

  • A Next.js project using the App Router (app/ directory).
  • A TryRoki account.
  • A publicly reachable HTTPS URL for your site (your production deploy, or a tunnel like ngrok/cloudflared for local testing).
There is no API key to request and nothing to npm install. The only credential is a secret you generate — it goes in your app’s env and in the webhook’s custom headers.

Step 1 — Add a shared secret

Generate a long random string and add it to your environment. Anything unguessable works:
terminal
.env.local
You’ll paste this same value into the TryRoki dashboard in Step 5.

Step 2 — Create the webhook route handler

Create app/api/tryroki/route.ts. It authenticates the request, parses the article, stores it, and responds 2xx quickly.
app/api/tryroki/route.ts
Your endpoint has 15 seconds to return a 2xx, and TryRoki does not retry failed deliveries. Keep the handler fast — offload image downloads, re-indexing, or notifications to a queue and respond immediately.

Step 3 — Store the article

Create app/lib/articles.ts. This example uses an in-memory Map so you can run it instantly — swap the bodies for your real database (Prisma, Drizzle, Postgres, a CMS, etc.) before deploying.
app/lib/articles.ts
The in-memory Map resets on every serverless cold start and isn’t shared across instances. It’s only for a first local test — persist to a real database in production.

Step 4 — Render the blog

TryRoki sends content_html already rendered, so the article pages are thin.
app/blog/page.tsx
app/blog/[slug]/page.tsx
content_html comes from a source you authenticate with your secret, so rendering it directly is fine. If you also expose user-submitted content, sanitize HTML with a library such as rehype-sanitize or DOMPurify.

Step 5 — Register the webhook in TryRoki

1

Open the webhook settings

In the TryRoki dashboard go to Integrations → Webhooks and click Add webhook.
2

Set the endpoint URL

Enter your route’s public URL, e.g. https://yourdomain.com/api/tryroki.
3

Choose events

Tick On create (article.created) and On update (article.updated).
4

Add the secret header

In Custom headers, paste a JSON object with your secret:
This must match TRYROKI_WEBHOOK_SECRET from Step 1 exactly.
5

Save

Save the webhook. TryRoki will POST to your endpoint on the next publish.

Step 6 — Test it

Simulate a delivery with curl (replace the domain and use the same secret):
terminal
Expect {"ok":true}. Open /blog and you’ll see the post; /blog/hello-from-tryroki renders the body. A 401 means the Authorization header doesn’t match your env secret.

Payload reference

The POST body is identical for article.created and article.updated. Full field table, event semantics, delivery timeouts, and security notes live in the webhook documentation.

Production checklist

  • Idempotency — upsert by id; the same article can arrive more than once.
  • HTTPS only — the secret rides in a header; never expose the endpoint over plain HTTP.
  • Fast response — return 2xx in under 15s; queue heavy work.
  • Real storage — replace the in-memory demo store with your database.
  • Revalidation — call revalidatePath (shown above) or use on-demand revalidation so new posts appear immediately.