Astro Static Tweet is an open-source Astro component that replaces JavaScript-based Twitter embeds with fully static HTML tweet displays.
What is Astro Static Tweet?
Astro Static Tweet is a component for the Astro static site generator that takes a tweet ID as a prop and returns a styled HTML representation of that tweet, fetched at build time from the Twitter API. Because the tweet is rendered as static markup, no Twitter JavaScript is loaded on the page, preserving site performance and privacy. The component is published on npm under @rebelchris/astro-static-tweet and its source is available on GitHub; the repository metadata shows 38 stars.
Key Features
- Fully static output — The component generates HTML with no client-side JavaScript, eliminating the runtime cost of Twitter's embed script.
- Simple component API — Use
<StaticTweet id="1359064894377762816" />inside any Astro file; the only required input is the numeric tweet ID. - Stylable markup — The rendered tweet is plain HTML/CSS, so you can restyle it to match your site's design system without fighting an iframe.
- Twitter API integration — Fetches tweet data through the official Twitter API using credentials you supply via environment variables (PUBLIC_TWITTER_API_KEY, PUBLIC_TWITTER_API_SECRET, PUBLIC_TWITTER_ACCESS_TOKEN, PUBLIC_TWITTER_ACCESS_TOKEN_SECRET).
- Astro-native — Works inside Astro's
.astrofiles and integrates with Astro's build pipeline; for Astro 0.22 or higher, you may need to marktwitter-api-clientas external inastro.config.mjs. - Open source — Free to use, with an issue tracker for feature requests; the author's roadmap includes styling guides and support for media, polls, videos, and multi-image tweets.
Who is it for?
- Static site developers using Astro who want to embed tweets without adding third-party JavaScript to their published site.
- Bloggers and content creators who quote tweets in articles and want a lightweight, accessible representation that doesn't depend on Twitter's embed library.
- Performance-focused front-end teams that track Core Web Vitals and need to eliminate render-blocking external scripts from embeds.
What can you do with Astro Static Tweet?
- Embed a specific tweet on a page by passing its ID, then customize the surrounding CSS to match your theme. The result is a tweet that works even if JavaScript is disabled.
- Build a curated timeline of static tweets on a landing page, testimonial page, or blog post without loading Twitter's widgets.
- Use it as a base for custom tweet components — since the output is plain markup, you can extend or redesign the component to show like counts, retweets, or original text differently.
How does Astro Static Tweet work?
- Install the package with
npm i @rebelchris/astro-static-tweet. - Import the
StaticTweetcomponent into an Astro file. - Create a
.envfile and add your Twitter API credentials as environment variables (the component reads them during the build). - Place
<StaticTweet id="1359064894377762816" />where you want the tweet to appear. - For Astro 0.22+, add
twitter-api-clientto the external list in your Vite/SSR config to avoid build errors.
Pros and cons
- Pros: No client-side JavaScript, static HTML output, fully customizable styling, simple one-prop interface, and an active open-source repository.
- Cons: Requires valid Twitter API credentials and setup; some tweet formats (media, polls, videos, multi-image, reactions) are not yet fully tested, as the repository's roadmap indicates.
FAQ
Is Astro Static Tweet free?
Yes, the component is open source and published under the @rebelchris npm scope. You can use it freely in personal and commercial projects, and the source code is available on GitHub.
Do I need Twitter API credentials?
Yes. The component calls the Twitter API at build time to fetch the tweet's content, so you must obtain a Twitter developer account and create an app to get API key, secret, access token, and access token secret. These are stored in a .env file.
Which Astro versions are supported?
The component works with Astro projects, but in Astro 0.22 or higher you need to exclude the twitter-api-client package from server-side rendering via the vite.ssr.external array in astro.config.mjs.
Can I customize the look of the tweet?
Yes. Unlike Twitter's standard embed, the static output is ordinary HTML and CSS, so you can override the styles to match your site's branding without relying on an iframe.
What tweet types are supported?
The component currently supports basic tweet text. Media, polls, videos, multi-image tweets, and reaction counts are listed as untested items on the project's roadmap, so these formats may not render completely until they are verified.







