React
React integration
Scaffold SimpleAuth hooks and UI into your React or Next.js project with the @simpleauthjs/react CLI.
@simpleauthjs/react is a command-line tool that copies auth primitives (a provider, client helper, hooks, forms, and modals) into your repository. It is not a runtime UI library: your application code imports the generated files under components/simpleauth/, not the npm package.
Why this pattern
- You own the source code and can change every line.
- You can adapt styling and behaviour to your product without waiting on library releases.
- There is no runtime dependency on a private component implementation.
- The workflow matches tools like shadcn/ui: copy, then customize.
What the CLI scaffolds
| Output | Description |
|---|---|
| SimpleAuthProvider | React context wiring for the browser client. |
| Client helper | getSimpleAuthClient() reading public env vars. |
| SignInForm / SignUpForm | Email and password forms wired to hooks. |
| SignInModal / SignUpModal | Accessible modal shells around the forms. |
| Hooks | useCurrentUser, useSignIn, useSignUp, and useSimpleAuthClient. |
Requirements
- React 18 or newer.
- TypeScript is recommended for the generated files.
- Next.js or Vite is supported out of the box. Other bundlers work as long as environment variables are statically inlined the same way.