Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@artshell/react-tiny-link

Package Overview
Dependencies
Maintainers
4
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@artshell/react-tiny-link

> Convert your links into beautiful previews

  • 3.6.3
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
27
increased by8%
Maintainers
4
Weekly downloads
 
Created
Source

Convert your links into beautiful previews

This is a fork of winhtaikaung/react-tiny-link with cache support waiting for PR #88 to be merged

Yet anotherReact link preview component with cards for web without a specific backend.

npm version npm GitHub code size in bytes NPM

All Contributors

NPM

CORS enabled?

No. You may need a CORS proxy to use this component. But if you dont have one, we made the component to use https://cors-anywhere.herokuapp.com as default proxy. Thanks to Rob. It saves my time for accessing urls.

Installation


npm install --save react-tiny-link

Usage & Configuration

import { ReactTinyLink } from 'react-tiny-link'
;<ReactTinyLink
  cardSize="small"
  showGraphic={true}
  maxLine={2}
  minLine={1}
  url="https://www.amazon.com/Steve-Madden-Mens-Jagwar-10-5/dp/B016X44MKA/ref=lp_18637582011_1_1?srs=18637582011&ie=UTF8&qid=1550721409&sr=8-1"
/>

Props & methods

PropNameDescriptionPropTypevaluerequired
urlURL to be display as previewstringtrue
cardSizeSize of the cardstringdefault (small) small,largefalse
maxLineMaximum number of line to ellipsisnumber2false
minLineMinimum number of line to ellipsisnumber1false
widthWidth of the link preview cardnumberdefault(100vw)false
headerDefault Header contentstringnullfalse
descriptionDefault description contentstringnullfalse
proxyUrlProxy URL to pass that resolve CORSstringdefault(https://cors-anywhere.herokuapp.com)false
showGraphicBoolean value to display graphicsbooleandefault(true)false
autoPlayBoolean value to play the media if provided url is videobooleandefault(false)false
defaultMediaDefault value to provide the media for failure casesstringN.Afalse
noCacheDisables cache of link resultbooleandefault(false)false
onErrorError callback on when the url failed to fetchonError(error:Error)N.Afalse
onSuccessSuccess callback on when the url was fetched successfullyonSuccess(data:IResponseData)N.Afalse
onClickClick event which will allow to add custom implementation onClick event if it was not provided the component itself will render as <a></a>.onClick(e:Event,data:IResponseData)default(null)false
loadSecureUrlLoad only secure ( https:// ) resources. If no secure resource was found, then don't render the <img> and <video> elementbooleandefault(false)false
requestHeadersRequest headers that will override the fetch headersRecord<string, string>;default(false)false

Hook usage

import { useScrapper } from 'react-tiny-link'

const [result, loading, error] = useScrapper({
  url:
    'https://www.amazon.com/Steve-Madden-Mens-Jagwar-10-5/dp/B016X44MKA/ref=lp_18637582011_1_1?srs=18637582011&ie=UTF8&qid=1550721409&sr=8-1',
})

Next.JS

For Next.Js you will have to turn off ssr false and use dynamic import. Because react-tiny-link uses styled-components as styling library which uses browser API window to attach scCGSHMRCache and stuffs after build.

import dynamic from "next/dynamic";
const ReactTinyLink = dynamic(
  () => {
    return import("react-tiny-link").then((mod) => mod.ReactTinyLink);
  },
  { ssr: false }
);

Params

PropNameDescriptionPropTypevaluerequired
urlURL to be display as previewstringtrue
proxyUrlProxy URL to pass that resolve CORSstringdefault(https://cors-anywhere.herokuapp.com)false
defaultMediasDefault value to provide the media for failure casesstring[]N.Afalse
defaultValueDefault response to provide for failure casesIReactTinyLinkDataN.Afalse
noCacheDisables cache of link resultbooleandefault(false)false
onErrorError callback on when the url failed to fetchonError(error:Error)N.Afalse
onSuccessSuccess callback on when the url was fetched successfullyonSuccess(data:IResponseData)N.Afalse

Demo App &

CodeSandbox

Edit React Tiny Link

Contributing

  1. Fork it

  2. Create your feature branch (git checkout -b my-new-feature)

  3. Commit your changes (git commit -am 'Added some feature')

  4. Push to the branch (git push origin my-new-feature)

  5. Create new Pull Request

Contributors

Thanks goes to these wonderful people (emoji key):


Vladimir Moushkov

💻

Serhii Khoma

💻 🐛

Hitesh Kumar

💻 🐛

VadymMoiseyenkoAgiliway

💻 🐛

nastikue

🐛

sndsabin

💻 🐛

Aviskar KC

🐛 💻

Alexandre Bernard

🐛 💻

Liz

💻 💡

This project follows the all-contributors specification. Contributions of any kind welcome!

License

MIT

Twitter Follow

Keywords

FAQs

Package last updated on 16 Sep 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc