Node.JS
The Civic Auth SDK also works with any Node.js backend.
The core integration points here are as follows:
-
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.
Use these guides to set up Civic Auth with any of the most common Node.js server libraries.
Usage
Civic Auth SDK is optimized for React and Next.js. However, some features are usable in other JS environments. For example, the getUser
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.
The name
property is used as an example here, check out the React Usage page to see the entire basic user object structure.