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

Extendify, version 3.0.4. 31 lines.

- Page: https://pluginprobe.com/plugins/extendify/3.0.4/code/src/AutoLaunch/hooks/useInstallRequiredPlugins.js
- Raw: https://pluginprobe.com/plugins/extendify/3.0.4/raw/src/AutoLaunch/hooks/useInstallRequiredPlugins.js
- Modified: 2026-04-27T19:36:32+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.0.4/code/src/AutoLaunch/hooks/useInstallRequiredPlugins.js#L10-L20`.

```javascript
import { handleSitePlugins } from '@auto-launch/fetchers/get-plugins';
import { activatePlugin, installPlugin } from '@auto-launch/functions/plugins';
import useSWR from 'swr/immutable';

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

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

	if (data?.sitePlugins?.sitePlugins?.length) {
		const pluginsToInstall = data.sitePlugins.sitePlugins.filter(
			({ wordpressSlug: slug }) => !installedPluginsSlugs?.includes(slug),
		);
		if (pluginsToInstall.length === 0) return;
		(async function install() {
			for (const { wordpressSlug: slug } of pluginsToInstall) {
				const p = await installPlugin(slug);
				await activatePlugin(p?.plugin ?? slug);
			}
		})();
	}

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

```
