Valora
API Reference@valora-ai/reactindexFunctions

usePersistentUserChoices

function usePersistentUserChoices(options?): {
  userChoices: PersistentUserChoices;
  saveAudioInputEnabled: (isEnabled) => void;
  saveVideoInputEnabled: (isEnabled) => void;
  saveAudioInputDeviceId: (deviceId) => void;
  saveVideoInputDeviceId: (deviceId) => void;
  saveUsername: (username) => void;
};

Defined in: packages/react/src/hooks/usePersistentUserChoices.ts:66

Access user choices stored in local storage, such as selected media devices, their on/off state, and the user name.

Parameters

Returns

{
  userChoices: PersistentUserChoices;
  saveAudioInputEnabled: (isEnabled) => void;
  saveVideoInputEnabled: (isEnabled) => void;
  saveAudioInputDeviceId: (deviceId) => void;
  saveVideoInputDeviceId: (deviceId) => void;
  saveUsername: (username) => void;
}

userChoices

userChoices: PersistentUserChoices;

saveAudioInputEnabled

saveAudioInputEnabled: (isEnabled) => void;

Parameters

ParameterType
isEnabledboolean

Returns

void

saveVideoInputEnabled

saveVideoInputEnabled: (isEnabled) => void;

Parameters

ParameterType
isEnabledboolean

Returns

void

saveAudioInputDeviceId

saveAudioInputDeviceId: (deviceId) => void;

Parameters

ParameterType
deviceIdstring

Returns

void

saveVideoInputDeviceId

saveVideoInputDeviceId: (deviceId) => void;

Parameters

ParameterType
deviceIdstring

Returns

void

saveUsername

saveUsername: (username) => void;

Parameters

ParameterType
usernamestring

Returns

void

Example

// Basic — persist a selected microphone.
const { userChoices, saveAudioInputDeviceId } = usePersistentUserChoices();
saveAudioInputDeviceId(userChoices.audioDeviceId);

// Advanced — start with defaults without loading storage.
function PreJoinChoices() {
  const { userChoices, saveUsername, saveAudioInputEnabled } = usePersistentUserChoices({
    defaults: { username: "Guest" },
    preventLoad: true,
  });

  return <input value={userChoices.username} onChange={(event) => saveUsername(event.target.value)} />;
}

On this page

Valora is local-first

No API key, no server — everything in this doc runs on-device.

Star on GitHub