React + JavaScript Integration
If your stack is React + JavaScript, this guide explains how to integrate Lucia's SDK. New to Lucia? Start with the Quickstart for the 5-minute path.
Prerequisites
- A React (or React + Redux) project
- A Lucia API key from your dashboard (Settings → API Keys)
- Environment variables configured in your
.envfile
Install the SDK
npm install lucia-sdk
# or
yarn add lucia-sdk
Initialize
import LuciaSDK from 'lucia-sdk';
LuciaSDK.init({
apiKey: process.env.REACT_APP_LUCIA_API_KEY,
});
Optional: you can pass a debug URL in the initialization parameters. This is typically only for internal use.
import LuciaSDK from 'lucia-sdk';
LuciaSDK.init({
apiKey: process.env.REACT_APP_LUCIA_API_KEY,
debugURL: process.env.REACT_APP_LUCIA_DEBUG_URL,
});
See the GitHub reference in our sandbox here.