-
Notifications
You must be signed in to change notification settings - Fork 68
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
Getting "document is not defined" with Next.js #80
Comments
see first section of this https://nextjs.org/docs/advanced-features/dynamic-import, splittingjs client-side work only |
Thanks for the reply, document error is resolved but I couldn't figure out
the way to get data-splitting attributes working in this way. I will really
appreciate a working demo for the same.
…On Fri, 31 Dec 2021 at 11:13, Jeff Zhang ***@***.***> wrote:
see first section of this
https://nextjs.org/docs/advanced-features/dynamic-import, client-side
work only
—
Reply to this email directly, view it on GitHub
<#80 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AW7WFILZJR4GKAHHFBEL5N3UTVCYRANCNFSM5K5URPBQ>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
I'm having this issue with Svelte. I think since everything is moving over to Vite we really need a ESM module as well as IIFE. |
Yes, I am having the same issue with next.js. A working solution with dynamic imports will be really appreciated. |
Hi, try: |
Also having some difficulties to get it to work in NextJS. I managed to bypass the document undefined using a dynamic import using
And this
But somehow, It's not just working. I would appreciate a solution regarding this @shshaw |
For anyone who is still struggling to use Splitting with Next.js, I combined all the answers from previous issues and I managed to get it working in with the following code: import "splitting/dist/splitting.css";
import "splitting/dist/splitting-cells.css";
const Component = () => {
let target;
setTimeout(() => {
if ( window && document && target ) {
const Splitting = require('Splitting');
Splitting({ by: "chars", target: target, });
}
});
return (
<>
<span ref={(el) => { target = el; }}>Lorem ipsum dolor sit amet</span>
</>
)
}
export default Component; |
Thank you for this @draZer0 |
Hi there,
I was trying your awesome library that works seamlessly without any framework. I tried it with Next.js and no matter what I do, I am constantly getting the error as attached "document is not defined". Any idea on how to solve this issue and use it with next.js.
The text was updated successfully, but these errors were encountered: