diff --git a/packages/next/client/index.tsx b/packages/next/client/index.tsx index fd44ba7a7b34..9b5086028300 100644 --- a/packages/next/client/index.tsx +++ b/packages/next/client/index.tsx @@ -289,6 +289,18 @@ export async function initialize(opts: { webpackHMR?: any } = {}): Promise<{ return { assetPrefix: prefix } } +const wrapApp = + (App: AppComponent) => + (wrappedAppProps: Record): JSX.Element => { + const appProps: AppProps = { + ...wrappedAppProps, + Component: CachedComponent, + err: initialData.err, + router, + } + return {renderApp(App, appProps)} + } + export async function hydrate(opts?: { beforeRender?: () => Promise }) { let initialErr = initialData.err @@ -396,18 +408,6 @@ export async function hydrate(opts?: { beforeRender?: () => Promise }) { await window.__NEXT_PRELOADREADY(initialData.dynamicIds) } - const wrapApp = - (App: AppComponent) => - (wrappedAppProps: Record): JSX.Element => { - const appProps: AppProps = { - ...wrappedAppProps, - Component: CachedComponent, - err: initialData.err, - router, - } - return {renderApp(App, appProps)} - } - router = createRouter(initialData.page, initialData.query, asPath, { initialProps: initialData.props, pageLoader,