- Direct users to the Civic Auth login page
- Set up an endpoint that the auth server should redirect to once complete
- Set up middleware to ensure only logged-in users can access protected parts of your app.
Usage
Civic Auth SDK is optimized for React and Next.js. However, some features are usable in other JS environments. For example, thegetUser
function verifies and parses the user information stored in the id_token cookie and makes it available to your app.
Getting User Information on the Backend
Here are some examples of using the getUser function in popular Node.JS server environments. Note - this snippet assumes you have followed the steps to integrate login with your app as described here. You have to provide a class that tells Civic how to load and store cookies, by implementing the CookieStorage interface. We provide examples for Express, Hono and Fastify.The
name
property is used as an example here, check out the React Usage page to see the entire basic user object structure.