Menu

1 / 2

How I built a 7,800-page nutrition site with Astro and Cloudflare Pages

DEV Community: astro·Miyuru Lakshitha·5 days ago
#XAlI0fIp
#devtoastro#devto#dev#pages#foods
Reading 0:00
15s threshold

A few weeks ago I wanted a simple answer: how much protein is in 100 g of cooked lentils? The top results were slow, covered in ads, or hid the numbers behind an app download. The data itself is public. The USDA publishes lab-measured nutrition values for thousands of foods for free.

So I built Nutrinfo : one fast page per food, generated straight from USDA data, plus a few calculators and an AI meal analyzer. This post covers how it is put together, with the real code.

The stack

Astro for static generation, with output: 'static'

Cloudflare Pages for hosting, with one Pages Function for the AI endpoint

GitHub Actions to build and deploy on every push to main

USDA FoodData Central, SR Legacy as the data source (7,793 foods, up to 150 nutrients each)

No database and no server. Every food page is plain HTML on Cloudflare's edge.

Step 1: turning a 200 MB JSON file into site data

USDA ships SR Legacy as one large JSON file.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.