Quickstart ⚡
Sign up your first user in 5 minutes
In this quickstart you’ll learn how to sign up your first user using Crossmint Auth, a fully managed authentication service provided by Crossmint.
Integration Steps
1. Create and Configure a Crossmint Project
To get started, create a developer account in the Crossmint Staging Console. Open that link, sign in, and accept the dialog to continue.
2. Get an API Key
Navigate to the "Integrate" section on the left navigation bar, and ensure you're on the "API Keys" tab.
Within the Client-side keys section, click the "Create new key" button in the top right.
On the authorized origins section, enter http://localhost:3000
and click "Add origin".
Next, check the scopes labeled users.create
.
Check the "JWT Auth" box
Finally, create your key and save it for subsequent steps.
3. Project Set Up
Create a new Next.js application
Use the create-next-app
package to get started:
If you see this message enter y
and Enter
to proceed:
Name your app `my-first-auth-app` and accept the default options
Change into the directory created in previous steps
Install the Crossmint React SDK
Add a new file named `.env.local` to root directory of your project
Set your environment variables by adding your client-side API secret from Step 1.
Prepare auth page
Open app/page.tsx
, delete the contents, and leave a minimal page, for next steps.
4. Set up Crossmint Auth
Configure Crossmint Auth in Layout
To configure auth, we need to create a new file for our Crossmint providers and then import it into our root layout.
Create a new file app/providers/Providers.tsx
and add the following code:
Now, open app/layout.tsx
and update it to use the new Providers component:
This setup encapsulates the Crossmint providers in a separate file, making your code more modular. The Providers
component wraps your application with both CrossmintProvider
and CrossmintAuthProvider
, configuring the
Crossmint SDK and auth.
Add login and logout functionality
Now, add the following import to the top of your page.tsx
file, below the "use client";
directive:
Next, declare a component that handles the login and logout functionality. This component uses the useAuth
hook to
manage authentication state and provides buttons for logging in and out.
Finally, add the AuthButton
component inside your Home
component.
Next steps
- Read and update user information
- Use webhooks to get notified when a user signs up
- Create Smart Wallets on sign up