# extendify/3.1.3/src/AutoLaunch/hooks/useInstallRequiredPlugins.js

Extendify, version 3.1.3. 29 lines.

- Page: https://pluginprobe.com/plugins/extendify/3.1.3/code/src/AutoLaunch/hooks/useInstallRequiredPlugins.js
- Raw: https://pluginprobe.com/plugins/extendify/3.1.3/raw/src/AutoLaunch/hooks/useInstallRequiredPlugins.js
- Modified: 2026-07-08T14:57:26+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/extendify/3.1.3/code/src/AutoLaunch/hooks/useInstallRequiredPlugins.js#L10-L20`.

```javascript
import { handleSitePlugins } from '@auto-launch/fetchers/get-plugins';
import { ensurePluginsActive } from '@auto-launch/functions/plugins';
import { useEffect, useRef } from '@wordpress/element';
import useSWR from 'swr/immutable';

const { installedPluginsSlugs } = window.extSharedData || {};

export const useInstallRequiredPlugins = () => {
	const { data, error } = useSWR('required-plugins', () =>
		handleSitePlugins({ requiredOnly: true }),
	);
	const started = useRef(false);

	useEffect(() => {
		if (started.current || !data?.sitePlugins?.length) return;
		started.current = true;
		ensurePluginsActive(
			data.sitePlugins.map(({ wordpressSlug }) => wordpressSlug),
			{ installedSlugs: installedPluginsSlugs },
		);
	}, [data]);

	return {
		requiredPlugins: data?.selectedPlugins || [],
		isLoading: !error && !data,
		isError: error,
	};
};

```
