Newsletter
Join the Community
Subscribe to our newsletter for the latest news and updates
Open-source Astro component that renders tweets as static HTML using the Twitter API, no JavaScript embeds.
Astro Static Tweet is an open-source Astro component that replaces JavaScript-based Twitter embeds with fully static HTML tweet displays.
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.
<StaticTweet id="1359064894377762816" /> inside any Astro file; the only required input is the numeric tweet ID..astro files and integrates with Astro's build pipeline; for Astro 0.22 or higher, you may need to mark twitter-api-client as external in astro.config.mjs.npm i @rebelchris/astro-static-tweet.StaticTweet component into an Astro file..env file and add your Twitter API credentials as environment variables (the component reads them during the build).<StaticTweet id="1359064894377762816" /> where you want the tweet to appear.twitter-api-client to the external list in your Vite/SSR config to avoid build errors.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.
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.
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.
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.
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.
