LucentProvider
Wraps your app, creates a singleLucentTracker instance, and manages
start/stop across the component lifetime.
Props
Your Lucent publishable key (
luc_pk_...). Safe to expose in client‑side
code — it can only write session data to your org and cannot read anything.Any option accepted by
LucentTracker except publicKey. See the
Configuration page for the full list.Your application tree.
Lifecycle
The provider creates the tracker lazily on first render. On mount it callstracker.start() (unless options.autoStart === false). On unmount it calls
tracker.stop(), which flushes any buffered events.
LucentIdentify
A renderless component that callstracker.identify(...) whenever its props
change, and tracker.resetIdentity() when userId becomes null. Use it to
sync your auth state with Lucent declaratively.
Props
Your internal user ID. When this transitions from a value to
null, Lucent
resets the identity and generates a new anonymous ID.Optional email address. Shown in the dashboard to help you find sessions.
Optional display name.
Arbitrary key/value pairs attached to the user. Useful for plan tier,
signup date, feature flags, etc.
useLucent
Returns the tracker instance from the nearestLucentProvider, or null if
called outside a provider. Use this when you want to track custom events or
manually flush.
Next.js notes
- Place
LucentProviderin a client component at the root of your app — typically directly insideapp/layout.tsx. You’ll need"use client"at the top of the file that renders the provider. - The provider is safe to render during SSR: all side effects happen inside
useEffect, which only runs in the browser. - Store your key in
NEXT_PUBLIC_LUCENT_PUBLIC_KEYand read it withprocess.env.NEXT_PUBLIC_LUCENT_PUBLIC_KEY.