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

Prerender detection #12

Open
redxtech opened this issue Aug 18, 2020 · 2 comments
Open

Prerender detection #12

redxtech opened this issue Aug 18, 2020 · 2 comments

Comments

@redxtech
Copy link

Hello! Is there any way for the app to tell whether it's being prerendered? I know that in react-snap you can check with navigator.userAgent === 'ReactSnap', so I'm wondering if there's an equivalent for this prerenderer. Thanks :)

@rakeshpai
Copy link
Member

I must admit I haven't used this project in a while myself, but I believe this is possible. You should have a global window.SNAPSHOT = true injected into the page when running.

window.SNAPSHOT = true; // eslint-disable-line no-undef

@rakeshpai
Copy link
Member

Yeah, this is documented in the README too:

Detecting snapshot

Sometimes, it may be necessary to detect if you are running in the snapshot mode, so that you can serve up alternative content. To enable this, a global window.SNAPSHOT variable is set to true when taking the snapshot.

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