/ Miscellaneous

A simple way to add twitter widgets to your react project

A simple way to add twitter widgets to your react project

React Twitter Embed Component

Simplest way to add twitter widgets to your react project.

Installation:

npm install --save react-twitter-embed

Sample Example:

Import in your view:

import { TwitterTimelineEmbed, TwitterShareButton, TwitterFollowButton, TwitterHashtagButton, TwitterMentionButton, TwitterTweetEmbed, TwitterMomentShare, TwitterDMButton, TwitterVideoEmbed, TwitterOnAirButton } from 'react-twitter-embed';

Adding Timeline:

 <TwitterTimelineEmbed
  sourceType="profile"
  screenName="saurabhnemade"
  options={{height: 400}}
/>

Adding Tweet:

<TwitterTweetEmbed
  tweetId={'933354946111705097'}
/>

Adding Share Button:

  <TwitterShareButton
    url={'https://facebook.com/saurabhnemade'}
    options={{ text: '#reactjs is awesome', via: 'saurabhnemade' }}
  />

Adding Mention Button:

  <TwitterMentionButton
    screenName={'saurabhnemade'}
  />

Adding Hashtag button:

  <TwitterHashtagButton
    tag={'cybersecurity'}
  />

Adding follow button:

  <TwitterFollowButton
    screenName={'saurabhnemade'}
  />

Adding Moment:

  <TwitterMomentShare
    momentId={'650667182356082688'}
  />

Adding Direct Messaging Button:

  <TwitterMomentShare
    id={1364031673}
  />

Adding Twitter Video:

  <TwitterVideoEmbed
    id={'560070183650213889'}
  />

Adding Twitter On Air Button:

  <TwitterOnAirButton
    id={'560070183650213889'}
  />

Explore All Options by Twitter Widgets API:

  https://developer.twitter.com/en/docs/twitter-for-websites/javascript-api/overview

GitHub