Skip to content

Why not write logic in Astro layouts

I wrote in Astro page layout and middleware execution order how I moved some logic to a layout.

Had to roll back because turns out I couldn’t run Astro.redirect() in a layout, since Astro tells me the response has already been sent to the client.

Turns out this was something I absolutely needed, so moved back to handling the logic in the pages, which was ultimately the right thing from the start.

Discovering new things each and every day.


I wrote 21 books to help you become a better developer:

  • HTML Handbook
  • Next.js Pages Router Handbook
  • Alpine.js Handbook
  • HTMX Handbook
  • TypeScript Handbook
  • React Handbook
  • SQL Handbook
  • Git Cheat Sheet
  • Laravel Handbook
  • Express Handbook
  • Swift Handbook
  • Go Handbook
  • PHP Handbook
  • Python Handbook
  • Linux Commands Handbook
  • C Handbook
  • JavaScript Handbook
  • Svelte Handbook
  • CSS Handbook
  • Node.js Handbook
  • Vue Handbook
...download them all now!

Also, JOIN MY CODING BOOTCAMP, an amazing cohort course that will be a huge step up in your coding career - covering React, Next.js - the 2025 edition, starting on February 4th, is now open for signups!

Bootcamp 2025

Signups open NOW!