tierra
NuxtImg & loading="lazy" load not fired after page route
Hi I am using NuxtImage with loading lazy like this
However this onLoad function is only fired once; but if I route between pages the images won't fade in anymore. Only on the first time. I fixed this by adding a placeholder to the image component, but not this placeholder causes the lazyloading not to work, but instead when I inspect the website it will immediately load all images, even outside the viewport.
Anyone has an idea on how to fix that?
I do not care about the placeholder, I simply want the image to fade in once it has loaded
11 replies
NuxtImage Fade In
Hello!
Can someone explain to me how I can add a basic fade effect after the image has been loaded?
I tried this
However, this works on first sight. But when I am switching pages back and forth. Images won't load again. It looks like as if cached images are not firing the load event anymore?
5 replies
NuxtImage Responsive Image Sizes
Hi everyone 👋
How do you use NuxtImage with srcset & sizes? Do you really set the sizes for each image you place in your project?
In the past I've used my own image component with lazysizes which has a auto sizes function where it detects the rendered image size and sets the correct data-sizes attribute, I think the same exists in Next image if I am correct.
I am a bit surprised this does not exist with NuxtImage yet, or does it? I also checked out unlazy which has something like this too: https://unlazy.byjohann.dev/guide/usage#auto-calculation-of-the-sizes-attribute
Am I overseeing something?
1 replies
Server API proxy caching approach
Hi all, I have a question regarding an approach to server api caching.
I am using Sanity IO as a backend and I'd like to cache my server routes which is no problem.
In my case right I have a filter function where a type (e.g. "posts") can be filtered with multiple tags, and I was wondering what the best approach is, because in my test queried cached routes did not work.
Since the amount of filters/tags is infinite, I was thinking of a post request and not a get request. But how would I cache this route since the post req is always different/can change?
One option I was thinking of is to have a cached route with all posts which then is fetched and filtered by the filtered route? Is that the correct approach? Or should I cache Route Parameters?
Whats the best way to approach this? Also the amount of posts is quite large, I am guessing around 1.000 entries
Thank you!
4 replies
SWR + NuxtLinks
Is there any way to have SWR + NuxtLinks which will not force a client side request?
I found similar issues on GitHub: https://github.com/nuxt/nuxt/issues/28212#issuecomment-2238562281
Is there any workaround to this? The only solution I can think of right now is to also cache the /api/ routes, but there should be a better way, right?
1 replies
Hydration Classname Mismatch Warnings
I keep getting Hydration Classname Mismatch Warnings and cannot get rid of them.
Basically, I am using
lazyssizes
for lazyloading and the plugin will change the class lazyload
to lazyloaded
on the client once images are loaded. Now I keep getting these errors in my log and have no idea how I would get rid of them?
On pages with 20 images I get 20 error logs which is a bit frustrating. Does anyone have an idea how I can get rid of them / solve the issue?
An example
13 replies
ISR Deployment Netlify (with Sanity)
Hey, until today it is not really clear to me how to properly deploy ISR on e.g. Netlify.
I am currently using Sanity as a backend and in my
/pages
files I am fetching files as such
My nuxt config looks like this:
But when I deploy this page, I can see that there are still network fetches on every route...
Can someone explain to me what I am not understanding / doing wrong?6 replies
Correct setup for `swr`
I have a question: Why is the setup below not working?
pages/index.vue
server/api/data.get.js
nuxt.config.js
This works below, but then I have to still do data fetches on every visit / route. But ideally I thought swr
would just fetch once every 60s or whatever and keep a static page?
nuxt.config.js
2 replies
How do you handle previews of static websites?
In Nuxt2 we had the preview plugin? But how do you handle it with nuxt3? I found this: https://github.com/nuxt/nuxt/issues/15639 but this does not really work for me yet
1 replies
Use nuxt-modules/apollo inside server/api
Can someone help me to understand how I can use https://github.com/nuxt-modules/apollo inside my
/server/api
?
I tried to use the client with const { clients } = useApollo();
but I get a annot access '_handle__get$1' before initialization
error.
Thanks!1 replies
asyncData updates before page transition is done
I am usign the
/server/api
and asyncData
to fetch the data.
Here is an example from my /pages/[slug].vue
:
however, when I am routing, the content is already changing while the page transition is still running. page transition is in out-in
mode though.
Anyone knows why this is happening? (I am on "nuxt": "^3.4.2"
)
Thanks!7 replies
Nested Route / Child Route Page Transitions
Is it possible to do Page Transitions with Child Routes? I found this GitHub Issue but am not sure if it is actually possible or a bug? https://github.com/nuxt/nuxt/issues/12361
1 replies
Nuxt 3 i18n (@nuxtjs/i18n)
Can anyone explain to me how to add i18n to Nuxt 3?
I am using pnpm and run into several issues:
When I start the server I see this error:
web dev: ERROR Cannot start nuxt: Cannot resolve vue-i18n on npm! please install it on 'node_modules'
2 replies
SWR Setup Netlify
Hello, can someone help me to understand
swr
settings for netlify? I would like to have swr settings to let's say refetch every 5min.
nuxt config:
Netlify Deploy settings are: yarn build
and output dist
. Somehow the site is doing API requests on every route though. So I don't think swr
is actually working.5 replies