Skip to content
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

Use in Nextjs #187

Open
kaisiant opened this issue Sep 14, 2021 · 5 comments
Open

Use in Nextjs #187

kaisiant opened this issue Sep 14, 2021 · 5 comments

Comments

@kaisiant
Copy link

import rough from "roughjs/bundled/rough.esm"
image

import rough from "roughjs/bin/rough"
image

I need some help, thanks

@pshihn
Copy link
Collaborator

pshihn commented Nov 3, 2021

Seems like you are having trouble loading es6 modules in next. Not sure how to configure that.
You can also try loading from roughjs/bundled/rough.cjs.js

@ShahriarKh
Copy link

ShahriarKh commented Feb 8, 2022

AFAIK it's resolved in Next 12.

@williamsjokvist
Copy link

AFAIK it's resolved in Next 12.

Can you get it working? No luck here, even tried using next-transpile-modules.

@museumhotel
Copy link

AFAIK it's resolved in Next 12.

Can you get it working? No luck here, even tried using next-transpile-modules.

was able to achieve rough-like effect in next using the thi.ng geom-fuzz library 🤷‍♂️

@ShahriarKh
Copy link

ShahriarKh commented Nov 10, 2022

Here is a simple example in Next:

import rough from "roughjs/bundled/rough.cjs.js";

export default function ComponentName() {
    useEffect(() => {
        let svg = document.getElementById('some-id');
        const rc = rough.svg(svg);
        let node = rc.circle(12, 12, 20);
        svg.appendChild(node);
    }, [])

    return <svg id='some-id' />
}

be sure to set height ad width for your <svg> element.
I'm using useEffect here to ensure the element is created in client-side (not server-side) and document is available.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants