imagekit-developer / imagekit-react

React SDK for using ImageKit.io
https://imagekit.io
MIT License
102 stars 28 forks source link

Next.js Image #87

Closed rimzzlabs closed 1 year ago

rimzzlabs commented 2 years ago

I'm looking for discussion, but it looks like this repo didn't enable the discussion feature, so here I am.

I'm using imagekit with nextjs, and my image were like very fast to deliver to the browser, thanks for the service, and here what's I'm gonna ask. What's the benefit using this SDK over Next.js Image? or is there something I'm missing out?

mayteio commented 2 years ago

I think there are trade-offs (https://docs.imagekit.io/getting-started/quickstart-guides/nextjs).

If you use next/image then you get responsive images - next.js will create different images for different viewports. You could probably work with this to accept a similar number of parameters that imagekit-react offers.

If you use imagekit-react then you can pass all parameters directly to the component with a nicer API, AND you can also leverage things like LQIP.

It would be great to have the best of both worlds.

JayeshVP24 commented 1 year ago

Hey @rizkimcitra, Well you have to create a custom loader for imagekitio to work with next/image.

The issues with next/image custom loader:

Advantages of using imagekit-react over custom loader

One drawback of imagekit-react I found is that it

Overcome the drawback

You can also mix and match, use all the three in the same project as per the use case. One thing which would be great for react is that if Imagekit-react made a API or function that takes all the transformation and just provides a URL which we can directly use in img tag, as they already have code for all the transformations.

There is an URL Builder but it's in imagekit-io core API https://github.com/imagekit-developer/imagekit-javascript

If we had this API in imagekit-react itself

Thank you, hope I this was helpful for you.

imagekitio commented 1 year ago

You can use IKCore https://github.com/imagekit-developer/imagekit-react#ikcore It exposes underlying ImageKit javascript core SDK which can be used to generate URL. Hope it helps.