Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .changeset/magic-link-fragment-code.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
"seamless-templates": patch
---

The web, fullstack and mobile starters move to the Seamless Auth SDK releases that support magic links carrying a code in their fragment (`/verify-magiclink?token=...#code=...`): `@seamless-auth/react` 0.21.0, `@seamless-auth/angular` 0.6.0, `@seamless-auth/vue` 0.5.0, `@seamless-auth/svelte` 0.5.0, `@seamless-auth/nextjs` 0.11.0 and `@seamless-auth/react-native` 0.6.0. The bundled verify screens strip the link from the address bar, confirm on their own when the link is opened on the device that asked for it, and send the code when the reader approves another device.

The Next.js starter's own verify page now uses `takeMagicLinkParams`, `verifyMagicLinkSignIn`, `finishMagicLinkSignIn` and `confirmMagicLinkSignIn` from `@seamless-auth/client`, a new direct dependency at 0.11.0. It reads the code from the fragment, which only the browser sees, so it no longer takes the token from the page's search parameters. It keeps working against auth APIs that do not send a code.

No starter passes its own magic link `redirectUri`, so every link goes to the auth API's default, `<frontend URL>/verify-magiclink`, which each web starter serves.
14 changes: 9 additions & 5 deletions templates/fullstack/nextjs/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,15 @@ when extending this app is to keep using them, not to rebuild them.
and `hasScopedRole`.
- `src/components/SignIn.tsx` and `src/components/VerifyMagicLink.tsx`: the sign-in UI, built on
`useAuth()` and `useAuthClient()`.
- When a magic link is opened on a different device from the one that asked for it, the auth server
answers the verify call with `409 confirmation_required` and does not spend the link.
`VerifyMagicLink.tsx` then shows which kind of device asked and when, and only on "Yes, sign in
that device" confirms it (`POST /auth/magic-link/verify/{token}/confirm`). The asking device then
signs in through its own poll, never this one. Keep the approval step.
- The emailed link is `/verify-magiclink?token=...#code=...`, and the auth server accepts no other
path unless `magic_link_redirect_uris` is configured. `VerifyMagicLink.tsx` reads it with
`takeMagicLinkParams` (which also strips it from the address bar) and verifies it with
`verifyMagicLinkSignIn` from `@seamless-auth/client`. The server holds every link until it is
confirmed with the fragment's code; the helper confirms on its own when the server reports the
link was opened on the device that asked. Opened on another device, the page shows which kind of
device asked and when, and only on "Yes, sign in that device" calls `confirmMagicLinkSignIn`. The
asking device then signs in through its own poll, never this one. Keep the approval step, and
never read the code from the server or log the link.

## Rules

Expand Down
53 changes: 27 additions & 26 deletions templates/fullstack/nextjs/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions templates/fullstack/nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@
},
"author": "Fells Code LLC",
"dependencies": {
"@seamless-auth/nextjs": "^0.9.0",
"@seamless-auth/react": "^0.20.0",
"@seamless-auth/client": "^0.11.0",
"@seamless-auth/nextjs": "^0.11.0",
"@seamless-auth/react": "^0.21.0",
"next": "^16.4.6",
"react": "^19.2.0",
"react-dom": "^19.2.0"
Expand Down
14 changes: 5 additions & 9 deletions templates/fullstack/nextjs/src/app/verify-magiclink/page.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
import AuthFrame from "@/components/AuthFrame";
import VerifyMagicLink from "@/components/VerifyMagicLink";

// The auth server builds the emailed link to this path, so it cannot be renamed.
export default async function VerifyMagicLinkPage({
searchParams,
}: {
searchParams: Promise<{ token?: string | string[] }>;
}) {
const { token } = await searchParams;

// The auth server builds the emailed link to this exact path, so it cannot be
// renamed. The link's code is in its fragment, which only the browser sees, so
// the client component reads the link rather than this page's searchParams.
export default function VerifyMagicLinkPage() {
return (
<AuthFrame>
<VerifyMagicLink token={Array.isArray(token) ? token[0] : token} />
<VerifyMagicLink />
</AuthFrame>
);
}
Loading
Loading