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

Question about getting the npm package to work #22

Open
kimzeevaarders opened this issue Nov 20, 2024 · 1 comment
Open

Question about getting the npm package to work #22

kimzeevaarders opened this issue Nov 20, 2024 · 1 comment

Comments

@kimzeevaarders
Copy link

Hi,

many thx for this magnificent project, I tried the script in our nextjs (pages router) application and it worked instantly 👍

Then I tried installing the npm package but it seems I get a window undefined exception if I call the scan method somewhere from our _app.tsx (our entry point to the app)

The readme state to put it somewhere BEFORE importing react but we don't implicitly import react in our project (gets removed by the kinter automatically stating this is unneccesary), so I disabled the linting and called it from our _app.tsx exactly like stated in the docs 🤷

Before I start deep-diving, one question: does your project support SSR rendering using next? Since I guess the first server is done on the server and there is no window object there of course 🤔

If not supported, is there some way to tweak the options using the script variant?

Hope to hear from you!

@aidenybai
Copy link
Owner

@kimzeevaarders it should support SSR - super weird. can you try importing a client script into the _app.tsx, something like:

client-file.ts

import { scan } from '...'

// rest of your code

_app.jsx

import { scan } from '...'
import React from '...'

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

2 participants