@passflow/react 0.26.2 → 0.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/README.md +72 -0
  3. package/dist/index.cjs +2 -1
  4. package/dist/index.cjs.map +1 -1
  5. package/dist/index.es.js +95 -94
  6. package/dist/index.es.js.map +1 -1
  7. package/dist/src/components/flow/consent/index.d.cts +1 -11
  8. package/dist/src/components/flow/consent/index.d.ts +1 -11
  9. package/dist/src/components/flow/consent/index.d.ts.map +1 -1
  10. package/dist/src/components/flow/device-verify/index.d.cts +1 -8
  11. package/dist/src/components/flow/device-verify/index.d.ts +1 -8
  12. package/dist/src/components/flow/device-verify/index.d.ts.map +1 -1
  13. package/dist/src/components/flow/two-factor-setup/index.d.ts.map +1 -1
  14. package/dist/src/components/flow/two-factor-setup-magic-link/index.d.cts +0 -13
  15. package/dist/src/components/flow/two-factor-setup-magic-link/index.d.ts +0 -13
  16. package/dist/src/components/flow/two-factor-setup-magic-link/index.d.ts.map +1 -1
  17. package/dist/src/components/flow/two-factor-verify/index.d.ts.map +1 -1
  18. package/dist/src/components/form/forgot-password/forgot-password-success.d.cts +1 -1
  19. package/dist/src/components/form/forgot-password/forgot-password-success.d.ts +1 -1
  20. package/dist/src/components/form/forgot-password/forgot-password-success.d.ts.map +1 -1
  21. package/dist/src/components/form/forgot-password/forgot-password.d.ts.map +1 -1
  22. package/dist/src/components/form/reset-password/index.d.ts.map +1 -1
  23. package/dist/src/components/form/signin/index.d.ts.map +1 -1
  24. package/dist/src/components/form/signup/index.d.ts.map +1 -1
  25. package/dist/src/components/form/two-factor-verify/two-factor-verify-form.d.ts.map +1 -1
  26. package/dist/src/components/form/verify-challenge/verify-challenge-magic-link.d.ts.map +1 -1
  27. package/dist/src/components/form/verify-challenge/verify-challenge-otp.d.ts.map +1 -1
  28. package/dist/src/components/provider/passflow-provider.d.ts.map +1 -1
  29. package/dist/src/components/provider/upgrade-provider.d.ts.map +1 -1
  30. package/dist/src/components/ui/fields/field-otp.d.cts +3 -5
  31. package/dist/src/components/ui/fields/field-otp.d.ts +3 -5
  32. package/dist/src/components/ui/fields/field-otp.d.ts.map +1 -1
  33. package/dist/src/components/ui/login-button/use-shadcn-theme.d.cts +1 -1
  34. package/dist/src/components/ui/login-button/use-shadcn-theme.d.ts +1 -1
  35. package/dist/src/components/ui/login-button/use-shadcn-theme.d.ts.map +1 -1
  36. package/dist/src/hocs/index.d.cts +1 -0
  37. package/dist/src/hocs/index.d.ts +1 -0
  38. package/dist/src/hocs/index.d.ts.map +1 -1
  39. package/dist/src/hocs/with-error.d.ts.map +1 -1
  40. package/dist/src/hocs/with-hydration.d.cts +8 -0
  41. package/dist/src/hocs/with-hydration.d.ts +8 -0
  42. package/dist/src/hocs/with-hydration.d.ts.map +1 -0
  43. package/dist/src/hooks/use-app-settings.d.ts.map +1 -1
  44. package/dist/src/hooks/use-isomorphic-layout-effect.d.cts +7 -0
  45. package/dist/src/hooks/use-isomorphic-layout-effect.d.ts +7 -0
  46. package/dist/src/hooks/use-isomorphic-layout-effect.d.ts.map +1 -0
  47. package/dist/src/hooks/use-trusted-devices.d.ts.map +1 -1
  48. package/dist/src/hooks/use-two-factor-status.d.ts.map +1 -1
  49. package/dist/src/hooks/use-user-passkeys.d.ts.map +1 -1
  50. package/package.json +2 -2
package/CHANGELOG.md CHANGED
@@ -2,6 +2,22 @@
2
2
 
3
3
  All notable changes to `@passflow/react` are documented in this file.
4
4
 
5
+ ## [0.27.0] - 2026-11-21
6
+
7
+ ### Fixed
8
+
9
+ - A server render in Node no longer throws `window is not defined`. `PassflowFlow` and every public screen render on the server with `PassflowProvider` around them. No component reads `window` or `document` during render.
10
+ - A screen that reads the URL or the session renders nothing on the server and in the hydration render. It shows its content in the render right after hydration, so the server HTML and the browser's first render match. This covers `PassflowFlow`, `SignIn`, `SignUp`, `SignInForm`, `SignUpForm`, `InvitationJoin`, `ForgotPassword`, `ForgotPasswordSuccess`, `ResetPassword`, `VerifyChallengeOTP`, `VerifyChallengeMagicLink`, `TwoFactorVerifyFlow`, `TwoFactorVerifyForm`, `TwoFactorSetupFlow`, `TwoFactorSetupMagicLinkFlow`, `ConsentFlow` and `DeviceVerifyFlow`. A page rendered only in the browser shows them from its first render, as before.
11
+ - On a server-rendered page, a sign-in landing that owes its second factor goes to the flow's own 2FA route, such as `/auth/two-factor-verify`. It went to `/two-factor-verify` when the flow had a `pathPrefix`.
12
+ - `next build` with `cacheComponents` no longer stops on "unstable value `crypto.randomUUID()` in a Client Component". `@passflow/core` 0.32.1 mints its device id when the first request goes out, not while `PassflowProvider` renders. The minimum `@passflow/core` is now 0.32.1.
13
+ - React 18 no longer warns "useLayoutEffect does nothing on the server" from `PassflowProvider` and the hooks under it.
14
+ - On React 18, `FieldOtp` passes its `ref` to the code input and no longer warns that `ref` is not a prop.
15
+
16
+ ### Added
17
+
18
+ - The bundles start with `'use client'`. A Next.js server component, such as `app/layout.tsx`, can import `PassflowProvider` and the other components from `@passflow/react` directly, with no `'use client'` wrapper of its own. Before, its build stopped on "Export Controller doesn't exist in target module".
19
+ - The README shows how to mount `PassflowFlow` in a Next.js App Router app: on an optional catch-all route under a prefix (`app/auth/[[...passflow]]/page.tsx`), so a reload of any flow path reaches the flow page; with `location` and `navigate` from Next.js's router, so leaving the flow loads the next page; and with the provider in the route's layout. A flow at the root uses `app/page.tsx` plus a required catch-all, `app/[...passflow]/page.tsx`, with `pathPrefix=""`.
20
+
5
21
  ## [0.26.2] - 2026-11-20
6
22
 
7
23
  ### Fixed
package/README.md CHANGED
@@ -22,6 +22,7 @@ This is a SDK for react application.
22
22
  - [React Router](#react-router)
23
23
  - [Wouter](#wouter)
24
24
  - [TanStack Router](#tanstack-router)
25
+ - [Next.js (App Router)](#nextjs-app-router)
25
26
  - [Props](#props)
26
27
  - [PassflowProvider](#passflowprovider)
27
28
  - [Form Components](#form-components)
@@ -690,6 +691,77 @@ export const routerTree = rootRoute.addChildren([
690
691
  ]);
691
692
  ```
692
693
 
694
+ ### Next.js (App Router)
695
+
696
+ Three things make the flow work in the App Router:
697
+
698
+ - **A catch-all route.** The flow moves the address to `/auth/signin`, `/auth/signup`, `/auth/two-factor-verify` and its other paths. Mount it on an optional catch-all, `app/auth/[[...passflow]]/page.tsx`, so a reload of any of them reaches the flow page.
699
+ - **Next.js's router.** Pass the flow `location` and `navigate` from `next/navigation`. A change the flow makes to the address on its own does not load another page in Next.js, so leaving the flow, for example after sign-in, needs the router.
700
+ - **The provider in a layout.** `app/auth/layout.tsx` stays mounted while the flow moves between its paths, so the provider keeps its state. Give it `twoFactorVerifyPath`, the flow's second-factor path under the prefix. Without it, a sign-in that comes back owing a second factor can go to `/two-factor-verify` instead of `/auth/two-factor-verify`, because the flow behind the page's Suspense boundary has not told the provider its path yet.
701
+
702
+ The package is client code and says so (`'use client'`), so a server component, such as this layout, can import from it directly.
703
+
704
+ ```tsx
705
+ // app/auth/layout.tsx
706
+ import { PassflowProvider } from '@passflow/react';
707
+ import '@passflow/react/dist/style.css';
708
+ import type { ReactNode } from 'react';
709
+
710
+ export default function AuthLayout({ children }: { children: ReactNode }) {
711
+ return (
712
+ <PassflowProvider
713
+ url={process.env.NEXT_PUBLIC_PASSFLOW_URL}
714
+ appId={process.env.NEXT_PUBLIC_PASSFLOW_APP_ID}
715
+ twoFactorVerifyPath="/auth/two-factor-verify"
716
+ >
717
+ {children}
718
+ </PassflowProvider>
719
+ );
720
+ }
721
+ ```
722
+
723
+ The flow page is a client component: it reads Next.js's router and hands the flow a function.
724
+
725
+ ```tsx
726
+ // app/auth/[[...passflow]]/page.tsx
727
+ 'use client';
728
+
729
+ import { PassflowFlow } from '@passflow/react';
730
+ import { usePathname, useRouter, useSearchParams } from 'next/navigation';
731
+ import { Suspense } from 'react';
732
+
733
+ function Flow() {
734
+ const pathname = usePathname();
735
+ const searchParams = useSearchParams();
736
+ const router = useRouter();
737
+ return (
738
+ <PassflowFlow
739
+ pathPrefix="/auth"
740
+ successAuthRedirect="/dashboard"
741
+ location={{ pathname, search: searchParams.toString() }}
742
+ navigate={(to, { replace }) => {
743
+ const href = `${to.pathname}${to.search}${to.hash ?? ''}`;
744
+ if (replace) router.replace(href);
745
+ else router.push(href);
746
+ }}
747
+ />
748
+ );
749
+ }
750
+
751
+ // useSearchParams needs a Suspense boundary in a prerendered page.
752
+ export default function PassflowPage() {
753
+ return (
754
+ <Suspense>
755
+ <Flow />
756
+ </Suspense>
757
+ );
758
+ }
759
+ ```
760
+
761
+ **The flow at the root.** Next.js does not allow `app/[[...passflow]]/page.tsx` beside `app/page.tsx`. Put the provider around `children` in `app/layout.tsx`, render the flow from both `app/page.tsx` and a required catch-all, `app/[...passflow]/page.tsx`, and pass `pathPrefix=""` and `twoFactorVerifyPath="/two-factor-verify"`. Next.js's own routes, such as `/dashboard`, still win over the catch-all. Any other unknown path reaches the flow, which moves it to `/signin`, instead of a 404.
762
+
763
+ The URL and the session exist only in the browser. So the server renders the flow's screens as nothing, and the browser shows them right after hydration.
764
+
693
765
  ## Props
694
766
 
695
767
  ### PassflowProvider