Vizel API / react/src / useVizelContext
Function: useVizelContext()
ts
function useVizelContext(): Editor | null;Defined in: packages/react/src/components/VizelContext.tsx:56
Hook to access the editor instance from context.
Returns the editor directly (or null while it is still initializing). Throws when called outside of a VizelProvider / Vizel boundary.
Returns
Editor | null
Throws
Error if used outside of VizelProvider
Example
tsx
function BoldButton() {
const editor = useVizelContext();
if (!editor) return null;
return (
<button onClick={() => editor.chain().focus().toggleBold().run()}>
Bold
</button>
);
}