Installation
Simply runnpm install @rownd/remix or yarn add @rownd/remix.
Setup
The library provides a React provider for the client and a higher-order function for the server. In your app’sroot.tsx file, use the Remix Rownd provider to wrap children,
likely before other providers:
root.tsx
entry.server.ts file, add the Rownd handle request higher-order
function with your server’s request handler handleRequest:
entry.server.ts
Protected component
To protect a component from being accessed by unauthenticated users, you can use thewithRowndRequireSignIn higher-order component and the withRowndLoader
higher-order function.
Client-side API reference
Please see the React SDK for details on Rownd Client React API’s. Most API methods are made available via the Rownd Provider and its associateduseRownd React hook. Unless otherwise noted, we’re assuming that you’re using
hooks.
requestSignIn()
Trigger the Rownd sign in dialog-
auto_sign_in: boolean- whentrue, automatically trigger a sign-in attempt ifidentifieris included or an email address or phone number has already been set in the user data. -
identifier: string- an email address or phone number (in E164 format) to which a verification message may be sent. If the Rownd app is configured to allow unverified users, then sign-in will complete without verification if the user has not signed in previously.
signOut()
Sign out the user and clear their profile, returning them to a completely unauthenticated state.getAccessToken()
Retrieves the active, valid access token for the current user.waitForToken: boolean- whentrue, if no access token is present or if it’s expired, the promise will not resolve until a valid token is available. While unlikely, this could result in waiting forever.
is_initializing will be true until the Hub has fully loaded, recalled its
state, and resolved the current user’s authentication status. This usually takes
only a few milliseconds, but if you make decisions that depend on the
is_authenticated flag while is_initializing is still true, your code/logic
may not work as you expect.
is_authenticated
access_token
Represents the current access token for the user.user
Represents information about the current user, specifically their profile information. In the example below, we use the existing data to display the current value offirst_name in a form field, update a local copy of that data
as the user changes it, and then save the changes to Rownd once the user submits
the form.
setUser
ThesetUser function allows you to update a user’s profile information within the Rownd platform. You can modify user attributes such as first_name, last_name, and other properties by passing an object with the relevant fields.
setUserValue
ThesetUserValue function allows you to update a specific attribute of the user’s profile within the Rownd platform. Instead of passing an entire user object, you can update individual fields by specifying the key (attribute name) and value.
manageAccount()
ThemanageAccount() function allows users to view and update their profile information within the Rownd platform. This function opens the user’s account management interface, where they can review and modify personal details such as their name, email, and other profile attributes.
passkeys
Rownd offers passkey-based authentication, allowing users to create and authenticate using a secure passkey. Theregister function starts the process of creating a new passkey for the user, while the authenticate function validates an existing passkey to authenticate the user.
RequireSignIn
TheRequireSignIn component is a wrapper that triggers the sign-in process when the component it wraps is rendered. It ensures that the user is signed in before accessing the content of the wrapped component. If the user is not authenticated, the sign-in process will automatically begin when the component mounts.
SignedIn
TheSignedIn component is used to conditionally render its children only when the user is authenticated. If the user is not signed in, the wrapped content will not be displayed.
SignedOut
TheSignedOut component is the counterpart to SignedIn. It renders its children only when the user is not authenticated. If the user is signed in, the wrapped content will not be displayed.