-
-
Notifications
You must be signed in to change notification settings - Fork 643
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Next JS: SyntaxError: Cannot use import statement outside a module #1614
Comments
I am having the same issue for
I am not sure why Dexie itself is working for me. I did add this to my
@Simoneth let me know if that is helpful at all. |
I think this is an issue with nextjs not able to run ESM modules in the SSR part. Googling this ends up with other issues regarding nextjs and ESM modules. Since dexie shall run on client only so if you can omit dexie code from being imported on the SSR part, it should work better. There's a similar problem with Sveltekit that also use server-side rendering and all queries need to be omitted on SSR rendering: https://dexie.org/docs/Tutorial/Svelte#using-sveltekit. |
Upgrade dexie-react-hooks (and dexie-cloud-addon if using it) to latest and everything should just work. |
Hi,
I'm using your awesome library like:
import db from "src/components/Dexie/db";
and got this server side error "SyntaxError: Cannot use import statement outside a module".Any solution? I tried this:
const db = dynamic(import('src/components/Dexie/db'), { ssr: false })
but it's almost the same, I get the same error...and db is undefined.
The text was updated successfully, but these errors were encountered: