malte-wessel / react-textfit

React component to fit headlines and paragraphs into elements
http://malte-wessel.github.io/react-textfit/
MIT License
469 stars 143 forks source link

Does it work with Next.js #85

Closed avalero closed 2 years ago

avalero commented 2 years ago

I am trying to use this with Next.js without success. I've thought it might be related to server-side rendering. Could you confirm if if can work on Next?

Thanks!

V3RON commented 2 years ago

You should be able to use it using Next's dynamic and importing Textfit on the client side only.

const Textfit = dynamic(
  () => import('react-textfit').then(mod =>  Textfit,
  { ssr: false }
)

Let me know if that works for you.

avalero commented 2 years ago

I works like charm. Thank you very much for your answer!!