@devcycle/nextjs-sdk
Version:
The Next.js SDK for DevCycle!
35 lines • 1.56 kB
JavaScript
import { jsx as _jsx } from "react/jsx-runtime";
import hoistNonReactStatics from 'hoist-non-react-statics';
import { DevCycleProvider } from '@devcycle/react-client-sdk';
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
export const appWithDevCycle = (WrappedComponent, additionalOptions = {}) => {
const AppWithDevCycle = (props) => {
var _a;
const devcycleSSR = props.pageProps
._devcycleSSR;
const onServerside = typeof window === 'undefined';
if (!devcycleSSR) {
return _jsx(WrappedComponent, { ...props });
}
return (_jsx(DevCycleProvider, { config: {
sdkKey: devcycleSSR.sdkKey,
user: devcycleSSR.user,
options: {
...additionalOptions,
...(onServerside
? {
disableAutomaticEventLogging: true,
disableCustomEventLogging: true,
disableRealtimeUpdates: true,
}
: {}),
sdkPlatform: 'nextjs',
disableConfigCache: true,
bootstrapConfig: (_a = devcycleSSR.bucketedConfig) !== null && _a !== void 0 ? _a : undefined,
next: {},
},
}, children: _jsx(WrappedComponent, { ...props }) }));
};
return hoistNonReactStatics(AppWithDevCycle, WrappedComponent);
};
//# sourceMappingURL=appWithDevCycle.js.map