Skip to content

Instantly share code, notes, and snippets.

@jthegedus
Last active July 25, 2017 10:15
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 jthegedus/a2492375f09f000c5e9244286186f12f to your computer and use it in GitHub Desktop.
Save jthegedus/a2492375f09f000c5e9244286186f12f to your computer and use it in GitHub Desktop.
Cloud Functions for Firebase - NextJS example
# src/app/.gitignore
.next
// src/app/components/App.js
import Header from "./Header"
const App = ({ children }) =>
<main>
<Header />
{children}
</main>
export default App
// src/app/components/Header.js
import Link from "next/link"
export default ({ pathname }) =>
<header>
<Link href="/">
<a className={pathname === "/" && "is-active"}>Home</a>
</Link>{" "}
<Link href="/about">
<a className={pathname === "/about" && "is-active"}>About</a>
</Link>
</header>
// src/app/next.config.js
module.exports = {
distDir: "../functions/next"
}
// src/app/pages/about.js
import App from "../components/App"
export default () =>
<App>
<p>About Page</p>
</App>
// src/app/pages/index.js
import App from "../components/App"
export default () =>
<App>
<p>Index Page</p>
</App>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment