<- Blog

What I Think About Astro

Mert Turkmenoglu, 8/4/2023 3 min read

Astro logo

Astro logo


You are reading this article in a webpage that is built with Astro. It’s a new young web framework, and it’s kind of unique. If you look at their webpage, they are calling their approach as zero-JS frontend architecture. It’s focused on content and performance, and oh boy isn’t it fast.

Probably one of the major features of Astro is the ability to combine multiple UI frameworks. You can develop components with React, Vue, Svelte, etc. and use them in a single Astro page. You can develop one of your components with React, other one with Vue, and make your page double bloated with JS. Pretty nice. Jokes aside, if you need to mostly produce static content but need an interactive component that you can easily develop with a UI framework, than this approach is actually great. It gives you the flexibility.

Astro has a lot of integration options. TailwindCSS, Markdown, MDX, Rehype, CMS integrations, UI adapters, SSR adapters, Astro plugins, etc. Most of them also have pretty easy setup. If you are using Yarn, you just run yarn astro add tailwind and it automagically sets up everything for you.

You have a file based router and create .astro files for your pages. You can utilize JSX and write components. You don’t have reactivity, but you can have variables, props, and use some good old JS. You can also use TypeScript. You write these inside two ---s which is called frontmatter.

An example code from this website’s source code (we are two parallel universes ahead right now, meta-meta programming):

---
const links = [
    { href: '/blog', label: 'Blog' },
    { href: 'https://github.com/mertturkmenoglu', label: 'GitHub' },
    { href: 'https://www.linkedin.com/in/mert-turkmenoglu/', label: 'LinkedIn' },
    { href: 'https://twitter.com/capreaee', label: 'Twitter' },
]
---
<nav class="mt-4">
    <ul class="flex items-baseline gap-4 flex-wrap text-base sm:text-lg">
        {links.map((l) => (
            <li>
                <a
                    href={l.href}
                    class="font-bold text-accent transition-all duration-200 ease-in-out border border-accent px-4 py-1.5 rounded-lg hover:bg-accent hover:text-midnight"
                >
                    {l.label}
                </a>
            </li>
        ))}
    </ul>
</nav>

Cool things I found about Astro:

Things I didn’t like:

Conclusion

I liked Astro. I think I’ll continue to use it for my mostly static content websites. I like how it’s blazingly fast.