I'm trying to setup the built-in imgix loader for nextjs 12+.
When I look in the dom the srcsets are as follows: https://account.imgix.net/?url=%2Fhero.jpeg%26fm%3Dwebp&w=640&q=20
It appends this ?url= and the image isn't shown because of it. Not sure if there is something I'm missing or not understanding ?
Thank you in advance!
My setup:
Next.config.js
loader: "imgix",
path: "https://account.imgix.net/",
domains: ["account.imgix.net"],
Then I try to render a next/image component like so:
<Image
alt="hero"
src={`/hero.jpeg`}
fill
quality={20}
style={{
objectFit: "cover",
objectPosition: "20% center",
borderRadius: 10,
}}
priority
/>
As was mentioned in the first comment,
next/image
no longer supports global loader configurations. You have to use theloader
prop.However, if you'd like to avoid having to do this each time you use the component, you can use the React Provider Pattern to provide that prop to any
next/image
component you're using. This will remove the need to set it inline on each instance of the component.Take a look at this CodeSandbox where we use the Provider pattern to give all the Next
<Image />
components the same imgix loader configuration if you want to learn more.