3.6.1 • Published 3 years ago

react-tiny-link v3.6.1

Weekly downloads
2,420
License
MIT
Repository
-
Last release
3 years ago

React-Tiny-Link

Convert your links into beautiful previews

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',
})

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):

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

License

MIT

Twitter Follow

3.6.1

3 years ago

3.6.0

4 years ago

3.5.0

4 years ago

3.4.0

4 years ago

3.3.1

4 years ago

3.3.0

4 years ago

3.2.0

4 years ago

3.1.0

4 years ago

3.0.0

4 years ago

2.0.1

5 years ago

2.0.0

5 years ago

1.1.0

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago

0.1.0

5 years ago