Web sender complains on SSR's
Closed this issue · 3 comments
The web sender (@envyjs/web
) integrates happily with client-side requests being made, but when it is included in an application which performs server side renders, we get the following message and it refuses to establish the connection:
Attempted to use @envyjs/web in a non-browser environment
This message comes from this line of code, and so maybe we just need to include the @envyjs/node
sender here and use that in cases where typeof window === 'undefined'
Here you go. minimal repo https://github.com/FormidableLabs/envy-ssr-issue. I've given kevin access
It’s NextJs 13 app with an SSR fetch
Feel free to blow the repo away whenever
I’ve added readme with steps
Thanks for the repo @simonwilbert. I merged some code to our examples to include pages and app router and I have a semi working version that injects Envy into the webpack build.
The future configuration I am shooting for will look like this for Nextjs applications. This is similar to how Sentry.js is setup in Nextjs, and will autoinject into the server and client bundles.
// next.config.js
import { withEnvy } from '@envyjs/next';
const nextConfig = {};
const envyConfig = {
serviceName: 'next-app',
};
module.exports = withEnvy(nextConfig, envyConfig);
Stay tuned!
Added to milestone "Release Zero" - if just to remove the "Attempted to use @envyjs/web in a non-browser environment" console log message