The freestyle-astro-template is a boilerplate for deploying Astro.js sites to the freestyle.sh cloud platform, where data persistence is handled by cloudstate JavaScript objects instead of a traditional database.
What is the freestyle-astro-template?
The freestyle-astro-template is a starting point for building Astro.js applications on freestyle.sh, a cloud platform in early development that replaces traditional databases with persistent JavaScript objects. It takes an Astro project structure and adds the cloudstate integration needed to persist class instances automatically. The template produces a deployable site and demonstrates the cloudstate model with a simple Counter example. It is built on Astro, the web framework for content-driven sites like blogs, marketing, and e-commerce.
Key Features
- Cloudstate persistent objects — The @cloudstate decorator marks a class as persistent, so its data is automatically saved and can only be accessed through its methods.
- In-memory style code — Developers write JavaScript as if data lives in memory; freestyle handles storage and optimizes queries inside its cloudstate environment.
- Singleton via static id — Giving a class a static id, such as "counter", makes it a singleton referenceable from anywhere in the project.
- Frontend and backend access — Methods can be called from either backend or frontend code using the useCloud reference, and they execute on the database.
- Astro.js integration — Built on the Astro framework, the template is suited for content-driven sites such as blogs, marketing pages, and e-commerce storefronts.
- Simple deployment workflow — Go live with three commands: npx freestyle build, npx freestyle login (GitHub), and npx freestyle deploy.
Who is it for?
- Astro developers exploring database alternatives — Use the template to test freestyle's persistent object model without setting up a traditional database.
- Full-stack JavaScript developers — Build data-driven features in Astro projects while writing only class methods instead of SQL or ORM queries.
- Early adopters of freestyle.sh — The template is an official starting point for deploying to the platform, which is still in early development.
What can you do with it?
- Build a counter or CRUD example — Use the included Counter class to persist counts and practice the cloudstate pattern.
- Deploy an Astro site to freestyle.sh — Bundle and deploy with the provided npx freestyle commands.
- Prototype persistent data models — Create classes with the @cloudstate decorator for automatic persistence, ideal for quick experiments.
How does it work?
The template runs with Node.js version 19 or newer on macOS or Linux; Windows support is not yet available. During local development, npx freestyle dev starts the server, but cloudstate data is not persistent and resets when the dev server restarts. For production, run npx freestyle build, log in with npx freestyle login using GitHub, then deploy with npx freestyle deploy.
FAQ
Does the freestyle-astro-template require Node 19?
Yes, freestyle currently requires Node.js version 19 or later on macOS or Linux. Windows support is announced as coming soon.
Is cloudstate data persistent during local development?
No. The README states that cloudstate is not persistent during local development and will be cleared when the dev server restarts. If you significantly change your data models, restart to clear the data.
How do I deploy this Astro template?
Build the project with npx freestyle build, log in with npx freestyle login using your GitHub account, then run npx freestyle deploy to deploy to freestyle.sh.
What is cloudstate?
Cloudstate is freestyle's persistence layer that stores JavaScript class instances as data. The @cloudstate decorator makes a class's data persistent, and methods are executed inside the cloudstate database rather than on the web server.





