FusionAuth Node.js Client Library
The following client library is now deprecated in favor of the typescript client, as it can do everything this project can but with better type support and examples.
Node.js Client Library
The Node.js client library allows you to integrate FusionAuth with your Node application.
Source Code:
NPM Package:
To install the FusionAuth Node Client package run:
npm install @fusionauth/node-client
Please note that if you will be using this client library in front end code such as a web browser you will not have a secure way to store an API key. You may optionally pass a value of null
for the API key parameter and still make API requests that do not require an API key.
The following code assumes FusionAuth is running on http://localhost:9011
and uses an API key 6b87a398-39f2-4692-927b-13188a81a9a3
, you will need to supply your own API key, and if you are not running FusionAuth locally, your host parameter may be different.
Here is an example of using the retrieveUserByEmail
method to retrieve a User by an email address.
const {FusionAuthClient} = require('@fusionauth/node-client');
const client = new FusionAuthClient('6b87a398-39f2-4692-927b-13188a81a9a3', 'http://localhost:9011');
{/* Retrieve User by Email Address */}
client.retrieveUserByEmail('user@example.com')
.then(handleResponse);
function handleResponse (clientResponse) {
console.info(JSON.stringify(clientResponse.successResponse.user, null, 2));
}
Example Apps
- 5 minute guide - Code examples from the 5 minute guide
- AWS CloudFront redirect to URL - This example documents how to use a AWS CloudFront Function to redirect to country-specific URLs, such as a FusionAuth instance.
- Consents - Example using advanced registration forms and consents
- Deeplinking - Example returning users to the same page they logged in on
- Device grant - An example of the Device Authorization grant
- Family API - Demonstrates how to use the family API to grant access to restricted sections of a web app
- Family management - Family management and consent creation
- FusionAuth Centralized Sessions - Example of centralized sessions between two different custom applications
- FusionAuth SSO - Example of SSO between two different custom applications
- Gaming and device grant - Example using the Device Authorization grant to provide authentication to a game.
- Gatsby OAuth - An example of using Gatsby with the Authorization Code grant and PKCE
- Github Actions - This sample application demonstrates how to use a GitHub Action to run Playwright tests against a simple Node.js Express.js application that logs in with FusionAuth.
- JavaScript Express API quickstart - JavaScript Express quickstart tutorial showing how to integrate FusionAuth with a JavaScript Express API
- JavaScript Express quickstart - JavaScript Express quickstart tutorial showing how to integrate FusionAuth with a JavaScript Express application
- Javascript JWT - JWT creation and decoding examples with javascript
- JavaScript NextJS quickstart - JavaScript NextJS quickstart tutorial showing how to integrate FusionAuth with a JavaScript NextJS application
- JavaScript Remix quickstart - JavaScript Remix quickstart tutorial showing how to integrate FusionAuth with a JavaScript Remix application
- JWT Auth and a Microservices gateway - API gateway and microservices secured using JWT auth
- Magic links login - Next.js app which uses magic links for authentication
- Microservices gateway - API gateway and microservices
- Modern guide to OAuth - Code examples from the Modern Guide To OAuth
- Multi-tenant application - Two nodejs applications in different tenants, living in different domains.
- React Native quickstart - React Native quickstart tutorial showing how to integrate FusionAuth with a React Native mobile application
- Restrict Simultaneous Logins (Simple) - Demonstrates how to limit the number of devices a user can simultaneously log in from, asking them to sign out from an existing session in order to continue
- Restrict Simultaneous Logins (User-friendly) - Demonstrates how to limit the number of devices a user can simultaneously log in from, allowing them to sign out via interface from other sessions
- Twitter login - Node/express app which uses Twitter for authentication
- User actions example - Corresponds to the user actions guide tutorial
- WebAuthn - Helper code for WebAuthn ceremonies
- Webhooks - Example webhook listeners
Upgrade Policy
Besides the releases made to keep track of the FusionAuth API as mentioned above, SDKs and Client Libraries may periodically receive updates with bug fixes, security patches, tests, code samples, or documentation changes.
These releases may also update dependencies, language engines, and operating systems, as we’ll follow the deprecation and sunsetting policies of the underlying technologies that the libraries use.
This means that after a language, framework, or operating system is deprecated by their own maintainer, our SDKs and Client Libraries that depend on it will also be deprecated by us, and will eventually be updated to use a newer version.