-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
182 additions
and
14 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"open-next": patch | ||
--- | ||
|
||
Example: add NextAuth example |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,13 @@ | ||
import "../styles/global.css"; | ||
import { SessionProvider } from "next-auth/react"; | ||
|
||
export default function App({ Component, pageProps }) { | ||
return <Component {...pageProps} />; | ||
export default function App({ | ||
Component, | ||
pageProps: { session, ...pageProps }, | ||
}) { | ||
return ( | ||
<SessionProvider session={session}> | ||
<Component {...pageProps} /> | ||
</SessionProvider> | ||
); | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import NextAuth from "next-auth"; | ||
import GithubProvider from "next-auth/providers/github"; | ||
import { Config } from "sst/node/config"; | ||
|
||
export const authOptions = { | ||
providers: [ | ||
GithubProvider({ | ||
clientId: Config.GITHUB_CLIENT_ID, | ||
clientSecret: Config.GITHUB_CLIENT_SECRET, | ||
}), | ||
], | ||
}; | ||
|
||
export default NextAuth(authOptions); |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import Layout from "../components/layout"; | ||
import Link from "next/link"; | ||
import { useSession, signIn, signOut } from "next-auth/react"; | ||
|
||
function LoginButton() { | ||
const { data: session } = useSession(); | ||
if (session) { | ||
return ( | ||
<> | ||
Signed in as {session.user.email} <br /> | ||
<button onClick={() => signOut()}>Sign out</button> | ||
</> | ||
); | ||
} | ||
return ( | ||
<> | ||
Not signed in <br /> | ||
<button onClick={() => signIn()}>Sign in</button> | ||
</> | ||
); | ||
} | ||
|
||
export default function Page() { | ||
return ( | ||
<Layout> | ||
<article> | ||
<h1> | ||
NextAuth | ||
</h1> | ||
<hr /> | ||
<LoginButton /> | ||
<br /> | ||
<p> | ||
<b>Test 1:</b> Sign in, and your email is displayed. | ||
<br /> | ||
<b>Test 2:</b> Sign out, and your email is cleared. | ||
</p> | ||
</article> | ||
</Layout> | ||
); | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
fe6740b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
open-next – ./
open-next-sst-dev.vercel.app
open-next-git-main-sst-dev.vercel.app
open-next.vercel.app