Text Summarizer Template
- Next.js
- TypeScript
Turn any long text into its key sentences, with how much shorter it got and the reading time you saved.
A Next.js app that summarizes text. Paste an article, email thread or report, pick how many sentences to keep, and get the key sentences as a short list with how much shorter it is and how much reading time it saves. Save the summaries you want to keep. Use it as a reading tool, or lift the API route to add TL;DRs to your own newsletter, CMS or support inbox.

What it does
- You choose the length
- A slider sets how many key sentences to keep, from one to six.
- Time saved, at a glance
- Shows how much shorter the summary is, the word count before and after, and the reading time saved.
- Key points as a list
- Each kept sentence becomes a bullet, ready to copy into an email or a doc.
- Saved summaries
- Keep the summaries you want on the device, and delete them when you’re done.
- Keeps your key private
- The browser only talks to your own API route, which checks the text, caches answers and limits each visitor to 10 summaries a minute.
How it works
The API route: it checks the text and length, answers from the cache when it can, and calls Text Summarizer.
/** POST /api/summarize { text, sentences }: picks the key sentences of a passage. */
export async function POST(request: Request) {
const body = await request.json().catch(() => null);
const text = String(body?.text ?? '').trim().slice(0, MAX_CHARS);
const sentences = Math.min(10, Math.max(1, Math.round(Number(body?.sentences) || 3)));
if (!text) return fail('Paste some text to summarize');
if (text.split(/\s+/).length < 20 || (text.match(/[.!?](\s|$)/g) || []).length < 2) {
return fail('Paste at least a few sentences (20 words or more): there’s nothing to shorten yet');
}
const key = `summarize:${sentences}:${text}`;
const hit = fromCache<Summary>(key, TTL_MS);
if (hit) return Response.json(hit);
const blocked = guard(request);
if (blocked) return blocked;
return respond(async () => {
const data = await callApi<Summary>('textsummarizer', { json: { text, sentences } });
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 Text Summarizer 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": {
"originalWords": 67,
"summaryWords": 30,
"percentDifference": 44.78,
"summary": "Headlines can be used to focus the reader's attention on a particular (or main) part of the article. A news article can include accounts of eyewitnesses to the happening event."
}
}