Skip to content

Instantly share code, notes, and snippets.

@dabit3
Last active October 22, 2020 06:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dabit3/d4921b5fcda3b2821cfbcea6ecf0c54e to your computer and use it in GitHub Desktop.
Save dabit3/d4921b5fcda3b2821cfbcea6ecf0c54e to your computer and use it in GitHub Desktop.
Next.js + Amplify - pages/_app.js
// pages/_app.js
import '../styles/globals.css';
import { css } from 'emotion';
import Link from 'next/link';
import checkUser from '../helpers/checkUser';
import '../configureAmplify';
export default function MyApp({ Component, pageProps }) {
const user = checkUser();
return (
<div>
<nav className={navStyle}>
<AppLink title="Home" path="/" />
<AppLink title="Profile" path="/profile" />
{ user && <AppLink title="Create Post" path="/create-post" /> }
</nav>
<Component {...pageProps} />
</div>
)
}
const AppLink = ({ title, path }) => (
<Link href={path}>
<span className={linkStyle}>{title}</span>
</Link>
)
const linkStyle = css`
margin-right: 20px;
cursor: pointer;
`
const navStyle = css`
display: flex;
padding: 30px;
border-bottom: 1px solid #ddd;
`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment