Read session and user data in your Remix app with Clerk
Clerk provides a set of hooks and helpers that you can use to access the active session and user data in your Remix application. Here are examples of how to use these helpers in both the client and server-side to get you started.
The getAuth() helper allows you to access the Auth object, which includes the current user's userId. You can use the userId to protect your routes or get the user's data.
In the following example, the userId is passed to the Backend SDK's getUser() method to get the user's full User object. For information on how to use the Backend SDK, see the Backend SDK documentation.
The following example uses the useAuth() hook to access the current auth state, as well as helper methods to manage the current active session. The hook returns userId, which can be used to protect your routes.
The following example uses the useUser() hook to access the User object, which contains the current user's data such as their full name. The isLoaded and isSignedIn properties are used to handle the loading state and to check if the user is signed in, respectively.