helper-plugin
migration reference
This document has been written to help developers migrate their Strapi plugins and applications to not use the helper-plugin
package.
It lists every export that existed in the helper-plugin
package, in alphabetical order and grouped by domain.
It is strongly advised not to upgrade a critical or production-ready project from Strapi v4 to Strapi 5.
The content of migration resources might not be final yet. Migration resources are currently only provided to prepare you for the upgrade to Strapi 5 when it is released as a stable version.
Strapi 5 is currently only provided as a Release Candidate (RC) version and is not meant to be used in production yet.
Componentsβ
AnErrorOccurredβ
This component has been removed and refactored to be part of the Page
component exported from @strapi/strapi/admin
. You should use the Page
component from there:
// Before
import { AnErrorOccurred } from '@strapi/helper-plugin';
// After
import { Page } from '@strapi/strapi/admin';
const MyPage = () => {
// ...
if (error) {
return <Page.Error />;
}
// ...
};
CheckPermissionsβ
This component has been removed and not replaced. If you feel like you need this component, please open an issue on the Strapi repository to discuss your usecase.
CheckPagePermissionsβ
This component has been removed and refactored to be part of the Page
component exported from @strapi/strapi/admin
. You should use the Page
component from there:
// Before
import { CheckPagePermissions } from '@strapi/helper-plugin';
// After
import { Page } from '@strapi/strapi/admin';
const MyProtectedPage = () => {
return (
<Page.Protect permissions={[action: 'plugin::my-plugin.read']}>
<MyPage />
</Page.Protect>
);
};
The behaviour has slightly changed, where previously no permissions would redirect you to the root of the page, now it will render the NoPermissions
component.
ConfirmDialogβ
This component has been moved and refactored. It can be imported from the @strapi/strapi/admin
package:
// Before
import { ConfirmDialog } from '@strapi/helper-plugin';
// After
import { ConfirmDialog } from '@strapi/strapi/admin';
Please see the contributors documentation for the ConfirmDialog
component for more information.
ContentBoxβ
This component has been removed and not replaced. If you feel like you need this component, please open an issue on the Strapi repository to discuss your usecase.
DateTimePickerβ
This was aliasing the design-system. You should import the component from there:
// Before
import { DateTimePicker } from '@strapi/helper-plugin';
// After
import { DateTimePicker } from '@strapi/design-system';
DynamicTableβ
This component was previously deprecated and has now been removed. Similar to the deprecation notice, we recommend using the Table
component from @strapi/strapi/admin
.
EmptyBodyTableβ
This component has been removed and is part of the Table
component.
EmptyStateLayoutβ
This component has been removed and not replaced. You should use EmptyStateLayout
from @strapi/design-system
:
// Before
import { EmptyStateLayout } from '@strapi/helper-plugin';
// After
import { EmptyStateLayout } from '@strapi/design-system';
The props will be different. Please refer to the Strapi Design System documentation for the EmptyStateLayout
component.
FilterListURLQueryβ
This component was moved to the admin
package and can now be imported via the @strapi/strapi
package as part of the composite component Filters
:
// Before
import { FilterListURLQuery } from '@strapi/helper-plugin';
// After
import { Filters } from '@strapi/strapi/admin';
const MyComponent = () => {
return (
<Filters.Root>
<Filters.List />
</Filters.Root>
);
};
FilterPopoverURLQueryPropsβ
This component was moved to the admin
package and can now be imported via the @strapi/strapi
package as part of the composite component Filters
:
// Before
import { FilterPopoverURLQueryProps } from '@strapi/helper-plugin';
// After
import { Filters } from '@strapi/strapi/admin';
const MyComponent = () => {
return (
<Filters.Root>
<Filters.Trigger />
<Filters.Popover />
</Filters.Root>
);
};
Formβ
This component aliased Formik
, something we're working towards removing. The Form
component and its sibling exports from @strapi/strapi/admin
should be used instead:
// Before
import { Form } from '@strapi/helper-plugin';
// After
import { Form } from '@strapi/strapi/admin';
Users should note that any use of the Formik library will no longer work and instead should look at the contributors documentation for the Form
component.
GenericInputβ
This component has been removed and refactored to become the InputRenderer
component exported from @strapi/strapi/admin
. You should use the InputRenderer
component from there:
// Before
import { GenericInput } from '@strapi/helper-plugin';
// After
import { InputRenderer } from '@strapi/strapi/admin';
Note, that the InputRenderer
component has a different API, and you should refer to the documentation for the InputRenderer
component.
InjectionZoneβ
This component has been removed and not replaced. However, you can easily replicate this in your own project by using the useStrapiApp
hook:
const MyComponent = ({ area, ...compProps }) => {
const getPlugin = useStrapiApp('MyComponent', (state) => state.getPlugin);
const [pluginName, page, position] = area.split('.');
const plugin = getPlugin(pluginName);
const components = plugin?.getInjectedComponents(page, position);
if (!plugin || !components) {
return null;
}
return components.map(({ name, Component }) => <Component key={name} {...props} />);
};
Linkβ
This was aliasing the design-system and using the as
prop with react-router-dom
. You should import the component from there:
// Before
import { Link } from '@strapi/helper-plugin';
// After
import { Link } from '@strapi/design-system/v2';
import { NavLink } from 'react-router-dom';
const MyLink = () => {
return (
<Link as={NavLink} to="/my-link">
My Link
</Link>
);
};
LinkButtonβ
This was aliasing the design-system and using the as
prop with react-router-dom
. You should import the component from there:
// Before
import { LinkButton } from '@strapi/helper-plugin';
// After
import { LinkButton } from '@strapi/design-system/v2';
import { NavLink } from 'react-router-dom';
const MyLink = () => {
return (
<LinkButton as={NavLink} to="/my-link">
My Link
</LinkButton>
);
};
LoadingIndicatorPageβ
This component has been removed and refactored to be part of the Page
component exported from @strapi/strapi/admin
. You should use the Page
component from there:
// Before
import { LoadingIndicatorPage } from '@strapi/helper-plugin';
// After
import { Page } from '@strapi/strapi/admin';
const MyPage = () => {
// ...
if (isLoading) {
return <Page.Loading />;
}
// ...
};
NoContentβ
This component has been removed and not replaced, you should use the EmptyStateLayout
component from @strapi/design-system
.
NoMediaβ
This component has been removed and not replaced. If you feel like you need this component, please open an issue on the Strapi repository to discuss your usecase.
NoPermissionsβ
This component has been removed and refactored to be part of the Page
component exported from @strapi/strapi/admin
. You should use the Page
component from there:
// Before
import { NoPermissions } from '@strapi/helper-plugin';
// After
import { Page } from '@strapi/strapi/admin';
const MyPage = () => {
// ...
if (!canRead) {
return <Page.NoPermissions />;
}
// ...
};
NotAllowedInputβ
This component has been removed and not replaced. If you feel like you need this component, please open an issue on the Strapi repository to discuss your usecase. You can easily replicate this in your own project by using the TextInput
from @strapi/design-system
:
import { TextInput } from '@strapi/design-system';
const MyComponent = (props) => {
return (
<TextInput disabled placeholder="No permissions to see this field" type="text" {...props} />
);
};
PageSizeURLQueryβ
This component was moved to the admin
package and can now be imported via the @strapi/strapi
package as part of the composite component Pagination
:
// Before
import { PageSizeURLQuery } from '@strapi/helper-plugin';
// After
import { Pagination } from '@strapi/strapi/admin';
const MyComponent = () => {
return (
<Pagination.Root>
<Pagination.PageSize />
</Pagination.Root>
);
};
Note, there were some slightly behavioural changes i.e. the PageSize won't render if the lowest pageSize is 10 but you only have 9 entries. Due to the refactor some props will have moved and changed, please look at the contributors documentation for the Pagination component for more information.
PaginationURLQueryPropsβ
This component was moved to the admin
package and can now be imported via the @strapi/strapi
package as part of the composite component Pagination
:
// Before
import { PaginationURLQueryProps } from '@strapi/helper-plugin';
// After
import { Pagination } from '@strapi/strapi/admin';
const MyComponent = () => {
return (
<Pagination.Root pageCount={2}>
<Pagination.Links />
</Pagination.Root>
);
};
Note, there were some slightly behavioural changes i.e. the Links won't render if there are less than 2 pages. Due to the refactor some props will have moved and changed, please look at the documentation for the Pagination component for more information.
ReactSelectβ
This component has been removed and not replaced. If you feel like you need this component, please open an issue on the Strapi repository to discuss your usecase.
RelativeTimeβ
This component has been removed and not replaced. If you feel like you need this component, please open an issue on the Strapi repository to discuss your usecase.
SearchURLQueryβ
This component was removed and renamed to SearchInput
and can now be imported by the @strapi/strapi
package:
// Before
import { SearchURLQuery } from '@strapi/helper-plugin';
// After
import { SearchInput } from '@strapi/strapi/admin';
SettingsPageTitleβ
This component has been removed and not replaced. If you feel like you need this component, please open an issue on the Strapi repository to discuss your usecase.
Statusβ
This component should be imported from the @strapi/design-system
package:
// Before
import { Status } from '@strapi/helper-plugin';
// After
import { Status } from '@strapi/design-system';
Tableβ
This component should be imported from the @strapi/strapi/admin
package:
// Before
import { Table } from '@strapi/helper-plugin';
// After
import { Table } from '@strapi/strapi/admin';
Some of the props have changed, please refer to the contributors documentation for the Table
component.
Content Managerβ
contentManagementUtilRemoveFieldsFromDataβ
This function has been removed and not replaced. If you feel like you need this function, please open an issue on the Strapi repository to discuss your usecase.
formatContentTypeDataβ
This function has been removed and not replaced. If you feel like you need this function, please open an issue on the Strapi repository to discuss your usecase.
useCMEditViewDataManagerβ
This hook has been split into different hooks, each with more ability then it's previous:
- useDocument
- useDocumentLayout
- useDocumentRBAC
- useForm
// Before
import { useCMEditViewDataManager } from '@strapi/helper-plugin';
// After
import {
useDocument,
useDocumentActions,
useDocumentLayout,
useDocumentRBAC,
useForm,
} from '@strapi/strapi/admin/hooks';
Some common use cases are listed below:
// Before
const { slug, isSingleType, isCreatingEntry } = useCMEditViewDataManager();
// After
const { model, id, collectionType } = useDocument();
const isSingleType = collectionType === 'single-types';
const isCreatingEntry = id === 'create';
// Before
const { onPublish, onUnpublish } = useCMEditViewDataManager();
// After
const { publish, unpublish } = useDocumentActions();
// Before
const { layout } = useCMEditViewDataManager();
// After
const {
edit: { layout, components },
} = useDocumentLayout();
Featuresβ
AppInfoβ
This feature has been moved to @strapi/admin
and only the hook useStrapiApp
is now exported.
AutoReloadOverlayBlockerβ
This feature has been removed and not replaced. If you feel like you need this feature, please open an issue on the Strapi repository to discuss your usecase.
CustomFieldsβ
This feature has been removed and is part of the useStrapiApp
hook.
GuidedTourβ
This feature has been moved to @strapi/admin
and only the hook useGuidedTour
is now exported.
Libraryβ
This feature has been removed and is part of the useStrapiApp
hook.
Notificationsβ
This feature has been moved to the @strapi/admin
package and only the useNotifications
hook is exported. The message
property
can no longer be a TranslationMessage
and instead, only a string. If you were previously using the warning
type you should instead
use the danger
type and if you were using the softWarning
type you should use warning
. Finally, the return type is now an object.
// Before
import { useNotification } from '@strapi/helper-plugin';
const toggleNotification = useNotification();
toggleNotification({
type: 'warning',
message: {
id: 'my.message.id',
defaultMessage: 'My message',
},
});
// After
import { useNotification } from '@strapi/strapi/admin';
const { toggleNotification } = useNotification();
toggleNotification({
type: 'danger',
message: formatMessage({
id: 'my.message.id',
defaultMessage: 'My message',
}),
});
RBACβ
This feature has removed and not replaced. If you need to access the user's permissions you should use the useAuth
hook.
// Before
import { useRBACProvider } from '@strapi/helper-plugin';
const { allPermission, refetchPermissions } = useRBACProvider();
// After
import { useAuth } from '@strapi/strapi/admin';
const permissions = useAuth('COMPONENT_NAME', (state) => state.permissions);
const refetchPermission = useAuth('COMPONENT_NAME', (state) => state.refetchPermission);
OverlayBlockerβ
This feature has been removed and not replaced. If you feel like you need this feature, please open an issue on the Strapi repository to discuss your usecase.
StrapiAppβ
This feature has been moved to @strapi/admin
and only the hook useStrapiApp
is now exported.
Trackingβ
This feature has been moved to the @strapi/admin
package and only the useTracking
hook is exported.
Hooksβ
useAPIErrorHandlerβ
This hook has been removed. You should import it from the @strapi/strapi/admin
package:
// Before
import { useAPIErrorHandler } from '@strapi/helper-plugin';
// After
import { useAPIErrorHandler } from '@strapi/strapi/admin';
useCallbackRefβ
This hook has been removed. You should import it from the @strapi/design-system
package:
// Before
import { useCallbackRef } from '@strapi/helper-plugin';
// After
import { useCallbackRef } from '@strapi/design-system';
useClipboardβ
This hook has been removed and not replaced. If you feel like you need this hook, please open an issue on the Strapi repository to discuss your usecase.
useCollatorβ
This hook has been removed. You should import it from the @strapi/design-system
package:
// Before
import { useCollator } from '@strapi/helper-plugin';
// After
import { useCollator } from '@strapi/design-system';
useFetchClientβ
This hook has been removed. You should import it from the @strapi/strapi/admin
package:
// Before
import { useFetchClient } from '@strapi/helper-plugin';
// After
import { useFetchClient } from '@strapi/strapi/admin';
useFieldHintβ
This hook has been removed and not replaced. If you feel like you need this hook, please open an issue on the Strapi repository to discuss your usecase.
useFilterβ
This hook has been removed. You should import it from the @strapi/design-system
package:
// Before
import { useFilter } from '@strapi/helper-plugin';
// After
import { useFilter } from '@strapi/design-system';
useFocusInputFieldβ
This hook has been removed and not replaced. If you feel like you need this hook, please open an issue on the Strapi repository to discuss your usecase.
useFocusWhenNavigateβ
This hook has been removed and not replaced. If you feel like you need this hook, please open an issue on the Strapi repository to discuss your usecase.
useFormattedMessageβ
This hook has been removed and not replaced. If you feel like you need this hook, please open an issue on the Strapi repository to discuss your usecase.
useLockScrollβ
This hook has been removed and not replaced. If you feel like you need this hook, please open an issue on the Strapi repository to discuss your usecase.
useQueryβ
This hook has been removed and not replaced. If you feel like you need this hook, please open an issue on the Strapi repository to discuss your usecase.
useQueryParamsβ
This hook has been moved. You should import it from the @strapi/strapi/admin
package:
// Before
import { useQueryParams } from '@strapi/helper-plugin';
// After
import { useQueryParams } from '@strapi/strapi/admin';
useRBACβ
This hook has been moved. You should import it from the @strapi/strapi/admin
package:
// Before
import { useRBAC } from '@strapi/helper-plugin';
// After
import { useRBAC } from '@strapi/strapi/admin';
useSelectionStateβ
This hook has been removed and not replaced. If you feel like you need this hook, please open an issue on the Strapi repository to discuss your usecase.
Iconsβ
SortIconβ
This component has been removed and not replaced. If you feel like you need this function, please open an issue on the Strapi repository to discuss your usecase.
RemoveRoundedButtonβ
This component has been removed and not replaced. If you feel like you need this function, please open an issue on the Strapi repository to discuss your usecase.
Utilsβ
awaitToJsβ
This util has been removed and not replaced, use async / await with try / catch instead. If you feel like you need this util, please open an issue on the Strapi repository to discuss your usecase.
differenceβ
This util has been removed and not replaced. If you feel like you need this util, please open an issue on the Strapi repository to discuss your usecase.
findMatchingPermissionsβ
This util has been removed and not replaced. You should filter the permissions yourself. If you feel like you need this util, please open an issue on the Strapi repository to discuss your usecase.
formatPermissionsForRequestβ
This util has been removed and not replaced. You should format the permissions yourself. If you feel like you need this util, please open an issue on the Strapi repository to discuss your usecase.
getAPIInnerErrorsβ
This util has been removed and not replaced, use async / await with try / catch instead. If you feel like you need this util, please open an issue on the Strapi repository to discuss your usecase.
getFetchClientβ
This util has been removed. You should import it from the @strapi/strapi/admin
package:
// Before
import { getFetchClient } from '@strapi/helper-plugin';
// After
import { getFetchClient } from '@strapi/strapi/admin';
getFileExtensionβ
This util has been removed and not replaced. If you feel like you need this util, please open an issue on the Strapi repository to discuss your usecase.
getYupInnerErrorsβ
This util has been removed and not replaced. If you feel like you need this util, please open an issue on the Strapi repository to discuss your usecase.
hasPermissionsβ
This util has been removed. If you need to use it, you should use the checkUserHasPermissions
function from the useAuth
hook.
// Before
import { hasPermissions } from '@strapi/helper-plugin';
// After
import { useAuth } from '@strapi/strapi/admin';
const { checkUserHasPermissions } = useAuth(
'COMPONENT_NAME',
(state) => state.checkUserHasPermissions
);
normalizeAPIErrorβ
This util has been removed and not replaced. If you feel like you need this util, please open an issue on the Strapi repository to discuss your usecase.
prefixFileUrlWithBackendUrlβ
This util has been removed and not replaced. Use the strapi backendUrl to prefix the relative url if you need. If you feel like you need this util, please open an issue on the Strapi repository to discuss your usecase.
prefixPluginTranslationsβ
This util has been removed and not replaced. If you feel like you need this util, please open an issue on the Strapi repository to discuss your usecase.
pxToRemβ
This util has been removed and not replaced. You should use directly this code in place of the pxToRem:
// Before
pxToRem(
32
) // After
`${32 / 16}rem`;
// or
('2rem');
If you feel like you need this util, please open an issue on the Strapi repository to discuss your usecase.
requestβ
This util has been removed and not replaced.
You can use useFetchClient
from @strapi/admin/strapi-admin
.
import { useFetchClient } from '@strapi/admin/strapi-admin';
And you can use it like this
const { get } = useFetchClient();
const { data } = await get(requestURL);
If you feel like you need this util, please open an issue on the Strapi repository to discuss your usecase.
setHexOpacityβ
This util has been removed and not replaced, use the native CSS opacity property instead. If you feel like you need this util, please open an issue on the Strapi repository to discuss your usecase.
stopPropagationβ
This util has been removed and not replaced. If you feel like you need this util, please open an issue on the Strapi repository to discuss your usecase.
shouldCheckPermissionsβ
This util has been removed and not replaced. If you feel like you need this util, please open an issue on the Strapi repository to discuss your usecase.
translatedErrorsβ
This utils has been removed. You should import it from the @strapi/strapi/admin
package:
// Before
import { translatedErrors } from '@strapi/helper-plugin';
// After
import { translatedErrors } from '@strapi/strapi/admin';
If you feel like you need this util, please open an issue on the Strapi repository to discuss your usecase.
wrapAxiosInstanceβ
This util has been removed and not replaced. If you feel like you need this util, please open an issue on the Strapi repository to discuss your usecase.