import React from "react"; import { withIronSession } from "next-iron-session"; const PrivatePage = ({ user }) => (

Hello {user.email}

Secret things live here...

); export const getServerSideProps = withIronSession( async ({ req, res }) => { const user = req.session.get("user"); if (!user) { res.statusCode = 404; res.end(); return { props: {} }; } return { props: { user } }; }, { cookieName: "MYSITECOOKIE", cookieOptions: { secure: process.env.NODE_ENV === "production" ? true : false }, password: process.env.APPLICATION_SECRET } ); export default PrivatePage;