Skip to content
exwave.Docs

Get started with Auth

In this guide, you create a web app where people can sign up, verify their email and sign in with Exwave Auth. It takes a few minutes. Already have an app? Go to Add Auth to an existing app.

You need:

  • Access to the Auth private beta. If you don’t have it yet, ask for it on the waitlist page.
  • A platform in Nexus. An organization owner can create one with Create platform.
  • Node.js 20 or later.
  1. Turn on Auth and copy your key.

    In Nexus, open your platform and go to Auth. Select Turn on Auth, then copy the Publishable key. It starts with exw_pk_. The key only tells the libraries which platform to use, so it’s safe to put in browser code.

  2. Allow email links to open your app.

    Verification and password reset emails only link to addresses you allow. In Auth → Settings, add your development address to the Redirect URLs:

    http://localhost:3000
  3. Create the app.

    Choose Next.js if your site has its own server code. Choose React (Vite) for a single-page app with no server. Replace exw_pk_... with your key:

    Terminal window
    npm create exwave@latest my-app -- --template next --key exw_pk_...

    The command creates a my-app folder, installs the dependencies and writes your key to .env.local. With Next.js, it also writes a cookie secret there.

    No key yet? Leave out --key. The app then uses the local mock, a stand-in for Exwave Auth that runs on your machine.

  4. Start the app.

    Terminal window
    cd my-app
    npm run dev

    Open http://localhost:3000/sign-up (http://localhost:5173/sign-up with Vite) and create an account. Then open the link in the verification email. You’re signed in, and the home page shows Signed in as with your name.

The sign-in, sign-up, verification and password reset screens are now files in your app, in components/exwave/. Change them as you like: see Components.

The next and vite templates use plain React and CSS. To build with shadcn/ui and Tailwind CSS instead, use the next-shadcn template. It makes a Next.js app with:

  • every auth screen, in app/(auth)/
  • a home page that shows who’s signed in
  • an account page, /account, that only signed-in people can open
  • the server routes the screens call, in app/api/exwave/[...action]/route.ts
  • proxy.ts, which keeps sessions fresh
  • Exwave’s colors, in light or dark mode to match the system

First, do steps 1 and 2 above. Then create the app, with your key in place of exw_pk_...:

Terminal window
npm create exwave@latest my-app -- --template next-shadcn --key exw_pk_...

Then run cd my-app and npm run dev, as in step 4. As with the other templates, leave out --key to use the local mock.

You can make the same app with the shadcn CLI:

Terminal window
npx shadcn@latest create -t next -n my-app https://www.exwave.net/r/exwave-app.json

This writes .env.local with placeholder values. Replace them with your key and a cookie secret, as in step 3 below.

The screens are in components/exwave/. The app is already connected to Exwave’s registry, so you can add more Exwave components with npx shadcn@latest add @exwave/<name>. See Components.

These steps add Exwave Auth to a Next.js 16 app that uses the App Router, or to a React 19 single-page app. Choose your framework in the tabs.

First, do steps 1 and 2 of Create an app: turn on Auth, copy your publishable key, and add your development address to the Redirect URLs.

Each framework has its own package, built on @exwave-nexus/auth, the JavaScript client. If you’re using another framework, use @exwave-nexus/auth on its own (see Without React), or email [email protected] to ask us to support it.

The ready-made screens are shadcn/ui components. Not using shadcn? Skip step 2, and build your own screens with the hooks.

  1. Install the libraries.

    Terminal window
    npm install @exwave-nexus/auth @exwave-nexus/auth-react @exwave-nexus/auth-nextjs
  2. Add the screens from Exwave’s registry.

    Not using shadcn? Copy lib/exwave.ts, the route handler and proxy.ts from The files instead, then go to step 3.

    Terminal window
    npx shadcn@latest registry add "@exwave=https://www.exwave.net/r/{name}.json"
    npx shadcn@latest add @exwave/auth-nextjs

    The first command connects your app to Exwave’s registry. You only run it once per app. The second one adds:

    • the screens, in components/exwave/
    • a page for each screen, in app/(auth)/: /sign-in, /sign-up, /verify, /forgot-password and /reset-password
    • app/api/exwave/[...action]/route.ts, the routes the screens call
    • lib/exwave.ts, which sets up Exwave Auth on your server
    • proxy.ts, which keeps sessions fresh
  3. Set your key and a cookie secret.

    The cookie secret encrypts the session cookie. It must be at least 32 characters, and each environment, such as development and production, needs its own. To make one, run:

    Terminal window
    node -e "console.log(require('crypto').randomBytes(32).toString('base64'))"

    Put your key and the secret in .env.local. If you did step 2, the file already has both names, with placeholder values to replace.

    .env.local
    NEXT_PUBLIC_EXWAVE_PUBLISHABLE_KEY=exw_pk_...
    EXWAVE_COOKIE_SECRET=...
  4. Add the provider to your root layout.

    <ExwaveProvider> gives every screen the session. With initialState, the first render already knows who is signed in.

    app/layout.tsx
    import { ExwaveProvider } from "@exwave-nexus/auth-nextjs/client";
    import { exwave } from "@/lib/exwave";
    export default async function RootLayout({
    children,
    }: Readonly<{ children: React.ReactNode }>) {
    return (
    <html lang="en">
    <body>
    <ExwaveProvider initialState={await exwave.getAuthState()}>
    {children}
    </ExwaveProvider>
    </body>
    </html>
    );
    }
  5. Read the user on the server.

    exwave.getUser() returns the signed-in user, or null. This page sends people who aren’t signed in to the sign-in page, then back:

    app/account/page.tsx
    import { redirect } from "next/navigation";
    import { exwave } from "@/lib/exwave";
    export default async function AccountPage() {
    const user = await exwave.getUser();
    if (!user) redirect("/sign-in?redirect=/account");
    return <p>Signed in as {user.displayName}</p>;
    }

    To check that it works, run npm run dev and open http://localhost:3000/sign-up. Create an account and open the link in the verification email. Then /account shows your name.