1.3.2 • Published 3 years ago

expo-link-preview v1.3.2

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

expo-link-preview

Render URL links for Web & Twitter previews

render twitter preview

Built with react-native using expo.

Installation

# yarn
yarn add expo-link-preview

# npm
npm install expo-link-preview --save

Then import with

import LinkPreview from "expo-link-preview";

Note: You may also need to install dependencies react-native-opengraph-kit and javascript-time-ago.

Usage

Example:

import { View, StyleSheet } from "react-native";
import LinkPreview from "expo-link-preview";

export default function App() {
  return (
    <View style={styles.container}>
      <LinkPreview
        link="http://github.com"
      />
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
  },
});

Web

Web previews will automatically use OpenGraph information to populate the preview. If an image is present, LinkPreview will default to that, otherwise show a non-interactive web view of the page.

render web preview

Twitter

Twitter previews will automatically be used if the OpenGraph response returns site_name=Twitter. The Twitter preview automatically adjusts to handle basic tweets and up to four images.

render twitter preview

Props

PropRequired?TypeDescription
linktruestringThe link to render the preview. Links are automatically validated, but should be passed as a string value that begins with "https://".
onPressfalsefunctionThe onPress function is called whenever a user taps the preview.
containerColorfalsestringThe background color of the preview container. Defaults to iOS themed component.
borderColorfalsestringThe border color of the preview container. Defaults to iOS themed component.
titleColorfalsestringThe text color of the Header – typically the website title or the Twitter user name. Defaults to iOS themed component.
textColorfalsestringThe text color of the Text – typically the website description or the Twitter user handle and tweet. Defaults to iOS themed component.

Twitter-specific props

PropRequired?TypeDescription
twitterLogoColorfalsestringThe tint color of the Twitter logo. Defaults to Twitter Blue.
showLikesfalseboolEnable/disable the Likes counter. Defaults to true.
showRetweetsfalseboolEnable/disable the Retweets counter. Defaults to true.
showRepliesfalseboolEnable/disable the Replies counter. Defaults to true.

Color example

Example:

import { View, StyleSheet } from "react-native";
import LinkPreview from "expo-link-preview";

export default function App() {
  return (
    <View style={styles.container}>
      <LinkPreview
        link="http://github.com"
        containerColor={"pink"}
        titleColor={"blue"}
        textColor={"yellow"}
        borderColor={"red"}
      />
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
  },
});

web color render

Built by Tyler J. ✌️

1.3.2

3 years ago

1.3.1

3 years ago

1.3.0

3 years ago

1.2.6

3 years ago

1.2.5

3 years ago

1.2.4

3 years ago

1.2.3

3 years ago

1.2.2

3 years ago

1.2.1

3 years ago

1.2.0

3 years ago

1.1.0

3 years ago

1.0.0

3 years ago