Installation
Install the required dependencies:Configuration
-
Get your Rownd App Key:
- Sign up or log in at Rownd Dashboard
- Create/select your application
- Copy your App Key (e.g.,
key_xxxxxxxx) - Copy your App ID This is used to verify the audience.
-
Set up Convex:
- Follow the Convex Getting Started guide to initialize your backend and get your deployment URL.
RowndProvider Setup
Wrap your app withRowndProvider from @rownd/react/convex and pass both your Convex client and Rownd app key:
Server-side Usage
Add Rownd to your auth.config.js file.
Add these to your convex/auth.config.js file:
[! NOTE]
Ensure you have the app: in addition to your app-id.
For example, applicationID: “app:app_alksdjflakjvlkeja”
Mapping Rownd IDs in Convex
It is critical to keep a mapping of the Rownd user ID in your Convexusers table.This allows you to associate Rownd-authenticated users with your app’s data. Schema example:
ctx.auth.getUserIdentity() will return all of the claim data included in the user’s JWT. You can use the
subject value to map your internal users to Rownd user’s.
Accessing the Current User
To get the current authenticated user in any Convex function, always look up by the Rownd ID:Protecting Convex Functions
Always check for authentication and use the Rownd ID mapping to associate data with users:Client-side Usage
Using Rownd React SDK Features
After setting up theRowndProvider, you can use all other features of the @rownd/react SDK in your app as documented in the official Rownd docs.
The Rownd React SDK only handles client-side authentication state. For proper integration with Convex, you should use Convex’s authentication hooks and utilities to ensure server-side state is properly synchronized.
useStoreUserEffect to handle the authentication flow as outlined in these Convex docs
Example:
Best Practices & Tips
- Always map Rownd IDs:
Store the Rownd user ID (identity.subject) in youruserstable and use it as the primary lookup for all user-specific data. - Use indexes for efficient lookups:
Index youruserstable byrowndIdfor fast queries. - Optionally include additional profile data in JWT claims
You can use the Rownd Platform to setup profile data fields for inclusion in additional JWT claims. This makes them avaiable on the
ctx.auth.getUserIdentity()