malte-wessel/react-textfit

Does it work with Next.js

avalero opened this issue · 2 comments

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

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.

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