To ease the development process, of course!
But whenever we download a new library, it only increases the bundle size, which in turn decreases application performance and speed. And when it comes to large-scale and complex sites, this becomes the greatest of issues as this bundle size reaches unacceptably high levels.
This entirely fails the purpose of using any modern library or tool in the first place, and this is where we see Astro come for front-line rescue.
Let’s see how -
Astro is a static website bundler that delivers lightning fast-speed and a modern developer experience.
Though the developer’s community adopted itself to these challenges and came up with new solutions like server-side rendering, lazy-loading, pre-rendering, hybrid-rendering, etc., they still have to deal with a lot of difficulties with these methods as well.
It works like a static-site generator. So if you have ever used one, Astro would not be difficult to understand.
Astro aims to make every website ‘fast by default’ and makes it very difficult for you to build a slow site.
Here comes partial hydration into the picture-
When we talk about partial hydration, this is the concept behind the superfast-speed and high performance of Astro. It is also referred to by terms like ‘progressive hydration’ or ‘progressive enhancement’.
So whenever you need to run a UI component in the browser, Astro enables you to load only that particular component (with dependencies) and while you're running it, the rest of your site remains as static HTML and runs as such.
Astro follows the idea of Island structure, which is all about building entire websites using partial hydration. The term ‘ Island pattern ‘ was first introduced by Katie Sylor Miller.
The server rendering in the Island model is not centered on improving SEO or UX but focuses upon how pages are rendered to the browser.
This in turn facilitates faster loading and rendering of lightweight components individually without being barred by other heavier components. Also, as this model isolates each page into separate units, any performance issue in one unit won’t cause any direct impact upon other units.
This approach leads to better navigation, improved accessibility, and SEO optimization.
We have already discussed the core highlighting feature of Astro, i.e. Partial Hydration. Let’s go down into other important features-
With Astro, you can bring your favorite framework and start building applications without any further ado. It also means that you don’t need any prior knowledge of new syntax to get along with Astro.
You don’t need any configuration to enable the popular frameworks like React, Vue, Preact, and Svelte as Astro possesses built-in support for them. In case, you want to work with any other framework, you can add Astro support to it a via third-party renderer.
A renderer here is a plugin (npm package) that adds Astro support for new frameworks and includes all framework dependencies in the package, so you don’t have to install them by yourself.
Other features are-
However, as we see that Astro is still in the beta phase, we will be able to see more obvious features in its official release. Till then, you can start using it to build your next website.
Let’s get started with Astro-
# Make a new project directory, and navigate directly into it mkdir my-astro-project && cd $_ # prepare for liftoff... npm init astro # install dependencies npm install # start developing! npm run dev
Inside your Astro project structure, you will see the following files and folders-
├── src/ │ ├── components/ │ ├── layouts/ │ └── pages/ │ └── index.astro ├── public/ └── package.json
While often a poor-performing website is considered a failure of the developer, it turns out that many times the fault lies in the choice of framework and tools.
Now that the programming community is evolving and bringing more and more frameworks that claim to deliver a better user experience, we should move from the older choices and give the new ones a chance as well, given how well they suit the project requirements.
Thanks for reading till the end, folks!