Skip to content

Vizel API / react/src / useVizelAutoSave

Function: useVizelAutoSave()

ts
function useVizelAutoSave(editor, options?): UseVizelAutoSaveResult;

Defined in: packages/react/src/hooks/useVizelAutoSave.ts:56

Hook for auto-saving editor content with debouncing.

Parameters

ParameterTypeDescription
editorEditor | null | undefinedThe editor instance (or null while it is still initializing)
optionsVizelAutoSaveOptionsAuto-save configuration options

Returns

UseVizelAutoSaveResult

Auto-save state and controls

Example

tsx
function Editor() {
  const editor = useVizelEditor({ ... });
  const { status, lastSaved, save } = useVizelAutoSave(editor, {
    debounceMs: 2000,
    storage: 'localStorage',
    key: 'my-document',
  });

  return (
    <div>
      <VizelEditor editor={editor} />
      <VizelSaveIndicator status={status} lastSaved={lastSaved} />
    </div>
  );
}

Released under the MIT License.