Replit home pagelight logodark logo
  • Docs
  • Tutorials
  • Trust & Billing
  • Replit Teams
  • Changelog
  • May 2025
    • May 9, 2025
    • May 2, 2025
    April 2025
    • April 25, 2025
    • April 18, 2025
    • April 11, 2025
    • April 4, 2025
    March 2025
    • March 28, 2025
    • March 21, 2025
    • March 14, 2025
    • March 7, 2025
    February 2025
    • February 28, 2025
    • February 21, 2025
    • February 14, 2025
    • February 7, 2025
    January 2025
    • January 31, 2025
    • January 24, 2025
    • January 17, 2025
    • January 10, 2025
    • January 3, 2025
    December 2024
    • December 27, 2024
    • December 20, 2024
    • December 13, 2024
    • Start Building
    Replit home pagelight logodark logo
    • Start Building
    • Start Building
    Hooks

    Hooks

    Reference guide for React hooks that help you build Replit extensions. Includes hooks for file operations, theme management, and workspace integration.

    useReplit

    Establishes the handshake between the Replit and the extension and passes the API wrapper for usage inside a React component.

    useReplitEffect

    Fires a callback with the replit API wrapper upon the first component render and when its dependency array changes.

    useWatchTextFile

    Allows you to read and write to the contents of a file at the provided filePath.

    useActiveFile

    Returns the file actively focused on by the current user.

    useThemeValues

    Provides you with the global token color values of the current user’s theme.

    useTheme

    Returns all metadata on the current theme including syntax highlighting, description, HSL, token values, and more.

    useIsExtension

    Returns whether the handshake has been successfully established with the the Replit workspace. If the handshake is loading, undefined will be returned. After loading has finished, the hook will return a boolean.

    Was this page helpful?

    xlinkedinyoutube
    Powered by Mintlify