Skip to content

Instantly share code, notes, and snippets.

@nolimits4web
Created March 5, 2021 16:27
Show Gist options
  • Save nolimits4web/b65c3c6c97660022b042d8d18fe6c6a2 to your computer and use it in GitHub Desktop.
Save nolimits4web/b65c3c6c97660022b042d8d18fe6c6a2 to your computer and use it in GitHub Desktop.
getInitialProps
function MyApp({ Component, pageProps, userAgent }) {
// pass userAgent to Framework7's App component
return (
<App
url={url}
routes={routes}
userAgent={userAgent}
>
{/* ... */}
</App>
)
}
MyApp.getInitialProps = async ({ctx}) => {
// get user-agent string on server-side
if (ctx && ctx.req && ctx.req.headers) {
// pass it to our component props
return {
userAgent: ctx.req.headers['user-agent']
}
}
return {};
}
export default MyApp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment