Astro Weekly #54

New primitive proposed for session management within Astro applications, migrate an Astro blog to Deno Deploy, Astro Server Islands and React Suspense compared

Greetings, Astronauts.

In the spirit of Halloween, we’ve got both tricks and treats for you this week!

Unearth a new primitive for session management in Astro applications, learn how to migrate your Astro blog to Deno Deploy with scaringly great results, plus explore the haunting rivalry between Astro Server Islands and React Suspense.

What’s new with Astro 🗞️

Astro bringing back PHP

Astro.session primitive proposed 💍

Astro core maintainer, Matt Kane, has published a proposal for a Astro.session primitive that aims to simplify session management within Astro applications.

The feature draws inspiration from session handling in frameworks like PHP and Rails, allowing developers to store data scoped to a browser session without the limitations of cookie storage.

---
let cart = Astro.session.get('cart')
if (!cart) {
	cart = createNewCart()
	Astro.session.set('cart', cart)
}
---

<div>{cart.items.length} items</div>

The proposal emphasizes a simple key/value API, enabling lazy-loaded sessions that automatically manage session ID cookies. Additionally, it supports pluggable storage backends, which can be customized via a new configuration object, catering to modern serverless environments.

For further details, visit the GitHub discussion.

Astro Boosters 🚀

High-performance image and video delivery

Adding images or videos to an Astro project is easy. What's not easy is making sure they look perfect on your website and managing them at scale.

Imagine an e-commerce store with 4,321 products, all with a unique image that needs to be displayed in a grid. What if you now want to show them in a square? Are you realistically going to Photoshop each one? Or sure, you can script it, but are you going to manually do that each time you have new assets? Nah…

  • ✂️ You can simply set your new dimensions:
     <CldImage width={4321} height={1234} crop="fill"/>

  • 💅 Enhance the images:
    <CldImage enhance/>

  • ✨ Use Gen AI to replace the background:
    <CldImage replaceBackground="space galaxy"/>

  • 🧏 And most importantly, make sure those images all have proper alt text by automatically generating them with AI.

This is just scratching the surface… Cloudinary is the Image and Video API for Astro that saves you valuable time in delivering the best experience you can for your web and mobile apps.

Get a bonus 3 credits on your free Cloudinary account: cld.media/astroweeklydevs 

Astro Community 🧑‍🚀

Astrosaurus

Migrating an Astro Blog to Deno Deploy 🦕

Ian Bull outlines his journey migrating an Astro-based static site from Netlify to Deno Deploy to introduce dynamic capabilities while retaining static efficiency.

Ian explains the benefits of a hybrid setup, plus how to navigate challenges around configurations and dependencies with Astro and Deno 2.0.

Astro Server Islands vs React Suspense 🏝️

Server Islands, introduced in Astro 4.12, make it easy to combine high-performance static HTML and dynamic server-generated components.

Jack Herrington takes an in-depth look at Astro Server Islands, how they are implemented, and how they compare with React Suspense.

What else I’ve been reading this week 🤓

Check out these great posts from the Astro Community ↓

If you have something awesome you’d like to share with the Astro community, you can reach me at [email protected] or via DM on X

Astro on X 💫

What’s happening on Twitter X this week…

Astro Showcase 🤩

Check out these impressive projects built with Astro!

Would you like your work to be featured in our Astro Showcase? Get in touch at [email protected] or DM me on X

Learn how to make AI work for you

AI won’t take your job, but a person using AI might. That’s why 800,000+ professionals read The Rundown AI – the free newsletter that keeps you updated on the latest AI news and teaches you how to use it in just 5 minutes a day.

That’s all for this week, Astronauts.

Got something you’d like to share in Astro Weekly? Feel free to reach out to [email protected] or via DM on X.

Until next time, Happy Halloween!

– Nathan 🧟‍♂️