WordPress Site Editor - markhowellsmead/helpers GitHub Wiki

Are we in the Site Editor?

import { useSelect } from '@wordpress/data';

const isSiteEditor = useSelect((select) => {
    try {
        // If the core/edit-site store exists, we are in the Site Editor
        return !!select('core/edit-site');
    } catch (error) {
        return false; // If the store is not available, we are not in the Site Editor
    }
}, []);