Che cos'è il formato di file ASTRO?
Un file .astro è un componente utilizzato da Astro, un framework web open-source per siti focalizzati sui contenuti come blog, documentazione e pagine di marketing. Fred K. Schott ha creato Astro nel 2021, e ha raggiunto la versione stabile 1.0 nell'agosto 2022. Il progetto è ora mantenuto sotto licenza MIT dopo che Cloudflare ha acquisito la Astro Technology Company nel gennaio 2026.
Ogni file ha due parti divise da un separatore di codice ---. Sopra il separatore si trova lo script del componente, o frontmatter, scritto in JavaScript o TypeScript. Viene eseguito al momento della build per importare altri componenti, recuperare dati e dichiarare variabili. Sotto il separatore c'è il template, un blocco simile all'HTML che accetta espressioni {}, segnaposto <slot /> e tag <style> e <script> con ambito locale (scoped). La sintassi è un superset di .html e si legge in modo molto simile a JSX, sebbene utilizzi attributi standard in kebab-case.
Astro esegue il rendering dei componenti in HTML in anticipo e non invia JavaScript lato client per impostazione predefinita. Gli elementi interattivi vengono aggiunti selettivamente attraverso l'architettura «islands» utilizzando le direttive client:* sui componenti del framework.
Sicurezza e incolumità
RISCHIO: LOWAn .astro file is human-readable source text and cannot run on its own by double-clicking. It only executes when compiled by the Astro toolchain during a build. As with any project source, its frontmatter can contain JavaScript, so review files from untrusted repositories before running npm install or a build, since build scripts and dependencies (not the .astro file itself) are the real risk.
Dettagli del formato
in sintesi- ASTRO-VISION LifeSign / horoscope data - Some astrology software has used .astro for chart or profile data files. Unrelated to the web framework.
- Generic astronomy/astrology data exports - Occasionally seen as an ad hoc extension for star-chart or ephemeris data in niche tools.
Programmi che aprono file ASTRO
.astro files. .astro components. npm run dev or astro build to compile .astro files into HTML and preview the site. .astro files with full language support. astro dev and astro build in Terminal to run and compile the project. .astro files. npm run dev or npx astro build from the terminal to serve or compile .astro files. Dettagli tecnici
specifiche approfondite| Encoding | UTF-8 plain text |
| Byte order | Not applicable (text) |
| Container | None; single source file |
| Typical size | A few hundred bytes to tens of kilobytes |
| Structure | Two sections separated by a --- code fence: an optional component script (frontmatter) written in JavaScript/TypeScript that runs at build time or on the server, followed by a component template made of HTML-like markup with {} expressions, directives, <slot />, <style> and <script> tags. |
| Integrity | None built in |
| Platforms | Windows, macOS, Linux |
| Notes | Astro components render to HTML ahead of time and ship no client-side JavaScript runtime by default. Interactive framework components can be hydrated selectively using client:* directives (the islands architecture). The Astro compiler parses .astro files and outputs HTML plus any scoped CSS and hydration code. |
| Syntax Basis | Superset of HTML, close to JSX but using standard kebab-case HTML attributes |
| Runtime | Server/build-time rendering; no default client runtime |
| Language Support | JavaScript and TypeScript in the frontmatter, including top-level await |
| Rilasciato | 2021 |
| Ultima versione | Astro 6 (March 2026) |
| Specifica | docs.astro.build |
Conversioni ASTRO
Domande e risposte della community
chiesto dagli utentiAncora nessuna domanda - sii il primo a chiedere informazioni sui file ASTRO.
Domande frequenti
Come apro un file .astro?
Posso visualizzare un file .astro in un browser?
npm run dev o compilarlo con astro build, e Astro trasformerà il componente in HTML che il browser potrà poi visualizzare.Quale programma crea i file .astro?
.astro di esempio.Un file .astro è uguale a un file HTML?
Perché il mio file .astro ha del JavaScript in alto?
---, è lo script del componente o frontmatter. Viene eseguito al momento della build per importare componenti, recuperare dati e impostare variabili utilizzate nel template sottostante.