Astro Middleware and API Endpoints in Practice
Combine Astro middleware with server endpoints to build request pipelines: auth gates, rate limiting, CORS handling, and JSON APIs that share context through Astro.locals.
10 posts · page 1 of 1
Combine Astro middleware with server endpoints to build request pipelines: auth gates, rate limiting, CORS handling, and JSON APIs that share context through Astro.locals.
Understand Single Page Apps, Server-Side Rendering, and Static Site Generation — how each works, performance tradeoffs, SEO impact, and when to use which.
Learn how Astro ships zero JavaScript by default and only hydrates the interactive components you mark as islands.
Use Astro middleware to run code on every request: auth gates, locals injection, redirects, and response headers. Learn the onRequest signature, the next() flow, sequencing, and common production patterns.
Build JSON APIs and dynamic responses directly in Astro using server endpoints. Learn the file conventions, request and response shapes, dynamic params, and how to mix endpoints with static and SSR pages.
Compare Astro and Next.js across rendering models, performance defaults, ecosystem, and use cases to pick the right framework for your project.
Compare the main Next.js data fetching strategies and learn when to use server components, route handlers, SWR, or static generation in your apps.
A clear comparison of static, server-rendered, and incrementally regenerated pages in Next.js, with rules for choosing the right strategy.
Compare Next.js static export and server runtime modes. Understand when each shines, how features differ, and how to choose without painting yourself into a corner.
A practical guide to React Server Components: how they differ from client components, the rendering model, streaming, and when to reach for each.