File tree Expand file tree Collapse file tree 1 file changed +45
-0
lines changed
Expand file tree Collapse file tree 1 file changed +45
-0
lines changed Original file line number Diff line number Diff line change @@ -212,6 +212,51 @@ pnpm dev
212212yarn dev
213213```
214214
215+ ## Step 10: Embedded Login Page (Optional)
216+
217+ If you want to use an embedded login page instead of redirecting to Asgardeo, you can use the `SignIn` component:
218+
219+ Configure the path of the sign-in page in the `middleware.ts` file:
220+
221+ ```diff
222+ import { AsgardeoNext } from ' @asgardeo/nextjs' ;
223+ import { NextRequest } from ' next/server' ;
224+
225+ const asgardeo = new AsgardeoNext();
226+
227+ asgardeo.initialize({
228+ baseUrl: process.env.NEXT_PUBLIC_ASGARDEO_BASE_URL,
229+ clientId: process.env.NEXT_PUBLIC_ASGARDEO_CLIENT_ID,
230+ clientSecret: process.env.ASGARDEO_CLIENT_SECRET,
231+ + signInUrl: ' /signin' ,
232+ });
233+
234+ export async function middleware(request: NextRequest) {
235+ return await asgardeo.middleware(request);
236+ }
237+
238+ export const config = {
239+ matcher: [
240+ ' /(( ?! _next| [^? ]* \\.(?: html?| css| js(?! on)| jpe? g| webp| png| gif| svg| ttf| woff2 ?| ico| csv| docx?| xlsx?| zip| webmanifest)) .* )' ,
241+ ' /(api| trpc)(.* )' ,
242+ ],
243+ };
244+ ```
245+
246+ Then, create a new page for the sign-in component in `app/signin/page.tsx`:
247+
248+ ```tsx
249+ ' use client' ;
250+
251+ import {SignIn} from ' @asgardeo/nextjs' ;
252+
253+ export default function SignInPage() {
254+ return <SignIn />;
255+ }
256+ ```
257+
258+ Once you have set this up, clicking on the "Sign In" button will render the embedded login page instead of redirecting to Asgardeo.
259+
215260## Next Steps
216261
217262🎉 **Congratulations!** You' ve successfully integrated Asgardeo authentication into your Next.js app.
You can’t perform that action at this time.
0 commit comments