You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# [Scratch Auth with Next.js](https://scratch-auth.netlify.app/en/docs/nextjs/quickstart)
2
2
3
-
Scratch Auth is a simple OAuth service for Scratch. It provides developers with an easy-to-understand API and users with a smooth login experience. By using @scratch-auth/nextjs, you can easily implement OAuth functionality into your site.
3
+
Scratch Auth is a simple OAuth service for Scratch. It provides developers with an easy-to-understand API and users with a smooth login experience. By using @scratch-auth/nextjs, you can easily implement OAuth functionality into your site.
### [Adding a Session Verification Page](https://scratch-auth.netlify.app/en/docs/nextjs/quickstart#adding-a-session-verification-page)
27
+
28
+
This page will decode the session and verify account information. You need to add this file to the path of the `redirect_url` that you set in `scratch-auth.config.ts`. During the redirect, the session will be set in the `privateCode` parameter.
### [Adding an Authentication Button](https://scratch-auth.netlify.app/en/docs/nextjs/quickstart#adding-a-session-verification-page)
66
+
67
+
By using Scratch Auth’s pre-built components, you can control the content displayed for logged-in and logged-out users. First, create a header for users to log in or out. To do this, use the following:
68
+
69
+
-`<LogIned>`: The children of this component are displayed only when the user is logged in.
70
+
-`<LogOuted>`: The children of this component are displayed only when the user is logged out.
71
+
-`<UserButton />`: A pre-built component with styles ready to display the avatar of the logged-in user’s account.
72
+
-`<LogInButton />`: An unstyled component that links to the login page. In this example, since no properties or environment variables are specified for the login URL, the component will link to the login page of the account portal.
73
+
74
+
```tsx filename="app/page.tsx"
75
+
importReactfrom"react";
76
+
import {
77
+
LogInButton,
78
+
LogIned,
79
+
LogOuted,
80
+
UserButton,
81
+
} from"@scratch-auth/nextjs";
82
+
83
+
exportdefaultfunction Page() {
84
+
return (
85
+
<div>
86
+
<LogOuted>
87
+
<LogInButton />
88
+
</LogOuted>
89
+
<LogIned>
90
+
<UserButton />
91
+
</LogIned>
92
+
</div>
93
+
);
94
+
}
95
+
```
96
+
97
+
### [Adding the Package Configuration File](https://scratch-auth.netlify.app/en/docs/nextjs/quickstart#adding-the-package-configuration-file)
Copy file name to clipboardExpand all lines: packages/nextjs/package.json
+7-1Lines changed: 7 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
{
2
2
"name": "@scratch-auth/nextjs",
3
-
"version": "0.0.1-beta.8",
3
+
"version": "0.0.1-beta.9",
4
4
"description": "Scratch Auth is a simple OAuth service for Scratch. It provides developers with an easy-to-understand API and users with a smooth login experience. By using @scratch-auth/nextjs, you can easily implement OAuth functionality into your site.",
0 commit comments