Created
March 5, 2021 16:27
-
-
Save nolimits4web/b65c3c6c97660022b042d8d18fe6c6a2 to your computer and use it in GitHub Desktop.
getInitialProps
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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