swiper
swiper copied to clipboard
Swiper cause next.js can't revalidate.
Check that this is really a bug
- [X] I confirm
Reproduction link
I don't know if it possible to reproduce the bug in codesandbox...
Bug description
So in Swiper v7, it uses ESM Module. Next.js v12 also support it, everything is okay. But when it try to regenerate pages. It cause this error.

Expected Behavior
Next.js should regenerate pages.
Actual Behavior
Next.js can't regenerate pages --> It return the cached pages instead.
Swiper version
7.0.0
Platform/Target and Browser Versions
Chrome
Validations
- [X] Follow our Code of Conduct
- [X] Read the docs.
- [X] Check that there isn't already an issue that request the same feature to avoid creating a duplicate.
- [X] Make sure this is a Swiper issue and not a framework-specific issue
Would you like to open a PR for this bug?
- [ ] I'm willing to open a PR
Ive been experiencing this as well.
Ive been experiencing this as well.
Have the exakt same issue
I fixed this issue by downgrade Swiper to v6. Here is it's docs: https://swiper6.vercel.app/swiper-api#events
Note: v6's API is kinda different from v7, so be sure to check that out.
@hoangvu12 Do you have problem with revalidation using Swiper 6.7.5 aswell? Or did you fix this by "the old ordinary" way and using
const swiper = new Swiper('.swiper-container', {
// ...
});
I use 6.75 and get this error:
Error: Cannot find module '../../core'
@hoangvu12 Do you have problem with revalidation using Swiper 6.7.5 aswell? Or did you fix this by "the old ordinary" way and using
const swiper = new Swiper('.swiper-container', { // ... });I use 6.75 and get this error:
Error: Cannot find module '../../core'
No I used React component and it worked fine.
Hi @hoangvu12 How do you host your setup? Vercel? What Next version do you have? :D
Hi @hoangvu12 How do you host your setup? Vercel? What Next version do you have? :D
I'm hosting on Vercel, Next v12.
What Node version? Sorry if I ask a lot haha.
What Node version? Sorry if I ask a lot haha.
It's v16.13
Ok, So I added a .node-version with 14.17.0 in it which looked like it fixed it. I now have next 12.0.2 and Swiper 7.4.1
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Bump