All Projects → transitive-bullshit → React Static Tweets

transitive-bullshit / React Static Tweets

Licence: mit
Extremely fast static renderer for tweets.

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to React Static Tweets

download-tweets-ai-text-gen-plus
Python script to download public Tweets from a given Twitter account into a format suitable for AI text generation
Stars: ✭ 26 (-90.65%)
Mutual labels:  twitter, tweets
TwitterPiBot
A Python based bot for Raspberry Pi that grabs tweets with a specific hashtag and reads them out loud.
Stars: ✭ 85 (-69.42%)
Mutual labels:  twitter, tweets
gbkel-portfolio
💎 My personal website that's mainly powered by Next.js, my own style guide and a lot of other technologies.
Stars: ✭ 12 (-95.68%)
Mutual labels:  ssr, nextjs
detweet
delete tweets en masse
Stars: ✭ 14 (-94.96%)
Mutual labels:  twitter, tweets
React Storefront
Build and deploy e-commerce progressive web apps (PWAs) in record time.
Stars: ✭ 275 (-1.08%)
Mutual labels:  nextjs, ssr
congresstweets
Datasets of the daily Twitter output of Congress.
Stars: ✭ 76 (-72.66%)
Mutual labels:  twitter, tweets
Archive-Tweets
Archive and Delete Liked and Posted Tweets
Stars: ✭ 28 (-89.93%)
Mutual labels:  twitter, tweets
Firebase Functions Next Example
Host a Next.js SSR React app on Cloud Functions for Firebase with Firebase Hosting
Stars: ✭ 215 (-22.66%)
Mutual labels:  nextjs, ssr
shici
使用 next.js 与 graphql 做一个诗词小站
Stars: ✭ 79 (-71.58%)
Mutual labels:  ssr, nextjs
twitter-analytics-wrapper
A simple Python wrapper to download tweets data from the Twitter Analytics platform. Particularly interesting for the impressions metrics that are unavailable on current Twitter API. Also works for the videos data.
Stars: ✭ 44 (-84.17%)
Mutual labels:  twitter, tweets
Next Go
Production ready blog + boilerplate for Next.js 3.X
Stars: ✭ 254 (-8.63%)
Mutual labels:  nextjs, ssr
Twitter Scraper
Scrape the Twitter Frontend API without authentication.
Stars: ✭ 3,037 (+992.45%)
Mutual labels:  twitter, tweets
Next Boost
Add a cache layer for server-side-rendered pages with stale-while-revalidate. Can be considered as an implementation of next.js's Incremental Static Regeneration which works with getServerSideProps.
Stars: ✭ 239 (-14.03%)
Mutual labels:  nextjs, ssr
gnip
Connect to Gnip streaming API and manage rules
Stars: ✭ 28 (-89.93%)
Mutual labels:  twitter, tweets
Next Blog Firestore
Example of blog built with React, Next.js, Firebase Firestore, Styled-Component, Mobx State Tree and other cool technologies
Stars: ✭ 219 (-21.22%)
Mutual labels:  nextjs, ssr
awesome-twitter-bots
A Curated Collection of the Best Twitter Bots 🤖
Stars: ✭ 99 (-64.39%)
Mutual labels:  twitter, tweets
Mordred
[Experimental] Source data from anywhere, for Next.js, Nuxt.js, Eleventy and many more.
Stars: ✭ 208 (-25.18%)
Mutual labels:  nextjs, ssr
Next Blog
基于react(ssr)服务端框架next.js和antd-design搭建的个人博客
Stars: ✭ 214 (-23.02%)
Mutual labels:  nextjs, ssr
TwEater
A Python Bot for Scraping Conversations from Twitter
Stars: ✭ 16 (-94.24%)
Mutual labels:  twitter, tweets
archive-explorer-web
Browse your Twitter archive with a friendly, responsive, full experience, and quickly delete the tweets you don't want.
Stars: ✭ 19 (-93.17%)
Mutual labels:  twitter, tweets

React Static Tweets

React Static Tweets

Extremely fast static renderer for tweets.

NPM Build Status Prettier Code Formatting

Why?

Twitter's embedding SDK is horribly slow and inefficient. For embedding tweets on your site (including SSR), this solution is 10-100x faster! 🔥

This project takes Vercel's work on static tweet rendering and packages it up into two easy-to-use NPM packages.

Here's a before and after which makes it clear how big of a difference this makes in practice. The first page uses Twitter's official iframe embedding SDK, and the second page uses react-static-tweets.

This project is being used in production by super.so.

Features

Usage

The easiest way to get started is to render tweets client-side (which will fetch the tweet data on-the-fly).

import React from 'react'
import { Tweet } from 'react-static-tweets'

export default Example({ tweetId }) => (
  <Tweet id={tweetId} />
)

For more optimized SSR usage, you'll want to pre-fetch the tweet AST data server-side:

import React from 'react'
import { fetchTweetAst } from 'static-tweets'
import { Tweet } from 'react-static-tweets'

const tweetId = '1358199505280262150'

export const getStaticProps = async () => {
  try {
    const tweetAst = await fetchTweetAst(tweetId)

    return {
      props: {
        tweetId,
        tweetAst
      },
      revalidate: 10
    }
  } catch (err) {
    console.error('error fetching tweet info', err)

    throw err
  }
}

export default function Example({ tweetId, tweetAst }) {
  return <Tweet id={tweetId} ast={tweetAst} />
}

Styles

You'll need to import some CSS styles as well. If you're using Next.js, we recommend you put these in pages/_app:

import 'react-static-tweets/styles.css'

Next.js Example

Here's a full Next.js example project with the most important code in pages/[tweetId].tsx.

You can check out an example hosted live on Vercel. A more in-depth example via twitter search which provides an Algolia search UI on top of my personal twitter history (@transitive_bs).

For an example of more advanced usage and customization, check out nextjs-notion-starter-kit.

Packages

Package NPM Docs Environment Description
react-static-tweets NPM docs Browser + SSR Fast React renderer for Tweets.
static-tweets NPM docs Node.js Fetches tweet ASTs.

Credit

My main contribution is packaging the Vercel team's excellent work into two isolated packages: static-tweets for server-side fetching of tweet ASTs and react-static-tweets for client-side rendering as well as SSR.

  • Inspired by this demo from the Vercel team
  • And the underlying repo by Luis Alvarez
  • Most of the core code is adapted from Guillermo Rauch's blog
  • Converted the JS codebase to TypeScript
  • Removed styled-jsx because using a flat CSS file (with a .static-tweet class prefix) makes bundling for NPM easier
  • Fixed some minor formatting bugs

License

MIT © Travis Fischer

Support my OSS work by following me on twitter twitter

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].