Migration Guide
1.0.XX to 2.0.XX
Motivation behind breaking changes
resources
Making resources
property-based instead of component-based was necessary for Nextjs support. A property is also more flexible, dynamic and easier to configure compared to a component.
routerProvider
Router layer is abstracted from the core for mainly Nextjs support. This also creates the opportunity for any other router solution to be used.
Custom Pages
This is also related to abstracting away the router layer from core. Differences between (currently two) router provider are so big that adding a layer to cover both cases (possibly more in the future) is much harder to implement and maintain compared to letting everyone handle it with their own conventions. This also has the huge benefit of allowing maximum configurability for every respective provider.
🪄 Migrating your project automatically with refine-codemod ✨ (recommended)
@pankod/refine-codemod
package handles the breaking changes for your project automatically, without any manual steps. It migrates your project from 1.x.x
to 2.x.x
.
Just cd
into root folder of your project (where package.json
is contained) and run this command:
npx @pankod/refine-codemod refine1-to-refine2
And it's done. Now your project uses refine@2.x.x
.
Migrating your project manually
Updating the packages
Packages used by your app must be updated to ^2.xx.xx
- @pankod/refine
- @pankod/refine-airtable
- @pankod/refine-altogic
- @pankod/refine-graphql
- @pankod/refine-hasura
- @pankod/refine-nestjsx-crud
- @pankod/refine-nextjs-router
- @pankod/refine-react-router
- @pankod/refine-simple-rest
- @pankod/refine-strapi
- @pankod/refine-strapi-graphql
- @pankod/refine-supabase
npm i @pankod/refine@latest
npm i @pankod/refine-airtable@latest
npm i @pankod/refine-altogic@latest
npm i @pankod/refine-graphql@latest
npm i @pankod/refine-hasura@latest
npm i @pankod/refine-nestjsx-crud@latest
npm i @pankod/refine-nextjs-router@latest
npm i @pankod/refine-react-router@latest
npm i @pankod/refine-simple-rest@latest
npm i @pankod/refine-strapi@latest
npm i @pankod/refine-strapi-graphql@latest
npm i @pankod/refine-supabase@latest
<Resource/>
to resources
<Resource/>
is deprecated. Resources must be passed to resources
prop instead.
import { Refine } from "@pankod/refine";
import dataProvider from "@pankod/refine-json-server";
import "@pankod/refine/dist/styles.min.css";
import { PostList, PostCreate, PostEdit, PostShow } from "pages/posts";
const API_URL = "https://api.fake-rest.refine.dev";
const App: React.FC = () => {
return (
<Refine
dataProvider={dataProvider(API_URL)}
resources={[
{
name: "posts",
list: PostList,
create: PostCreate,
edit: PostEdit,
show: PostShow,
},
]}
/>
);
};
export default App;
routerProvider
<Refine/>
now requires a routerProvider
. You can use packages @pankod/refine-react-router or @pankod/refine-nextjs-router provided by refine.
- React Router
- Next.js Router
import { Refine } from "@pankod/refine";
import routerProvider from "@pankod/refine-react-router";
const App: React.FC = () => {
return <Refine routerProvider={routerProvider} />;
};
import { Refine } from "@pankod/refine";
import routerProvider from "@pankod/refine-nextjs-router";
const App: React.FC = () => {
return <Refine routerProvider={routerProvider} />;
};
Link
component
If you imported Link
component from @pankod/refine
, now you have to switch to @pankod/refine-react-router
package to get the Link
component. Like this:
// Old
// import { ..., Link } from "@pankod/refine";
// Now
import routerProvider from "@pankod/refine-react-router";
const Link = routerProvider.Link;
Custom Pages
routes
prop of <Refine/>
is deprecated. Custom routes must be handled by the router provider you choose. Refer to Custom Pages documentation for a detailed guide