TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published


With this tool, you can customize your refine data providers per resource. You can use different data providers for different resources, override one method for just one specific resource etc.

If you have a non-standard API or some endpoint that refine should hit and your data provider methods don't work for that endpoint, you can use this tool to override a method for that resource.

function customize(source: DataProvider, customizations?: CustomizationsType): DataProvider

customize function accepts a data provider and a customization configuration. Returns a data provider.


Specific override

export const dataProvider = customize(baseDataProvider, {
  posts: {
    getOne: () => {
      // specific getOne implementation ...

// baseDataProvider.getOne (not "posts")
dataProvider.getOne({ resource: "foo", ... }); 

// customized getOne ("posts" override)
dataProvider.getOne({ resource: "posts", ... });

Any invocation of any method of dataProvider triggers the same method in baseDataProvider except if the resource is "posts" for getOne method. If getOne method of dataProvider is invoked, for "posts" resource, the customized method runs.

Different data provider for a resource

export const dataProvider = customize(baseDataProvider, {
  posts: supabaseDataProvider,
  categories: supabaseDataProvider,

// baseDataProvider.getOne (no overrides for "foo")
dataProvider.getOne({ resource: "foo", ... }); 

// supabaseDataProvider.getOne ("posts" override)
dataProvider.getOne({ resource: "posts", ... });

// supabaseDataProvider.getOne ("categories" override)
dataProvider.getOne({ resource: "categories", ... });

In this example, posts and categories resources use a different data provider: supabaseDataProvider. Any request that is invoked for "posts" and "categories" goes through supabasedataProvider. Rest goes for baseDataProvider.

Advanced Customization

export const dataProvider = customize(baseDataProvider, {
  posts: supabaseDataProvider,
  categories: customize(supabaseDataProvider, {
    getMany: () => {
      // specific getMany implementation ...

// baseDataProvider.getOne (no overrides)
dataProvider.getOne({ resource: "foo", ... }); 

// supabaseDataProvider.getOne (for "categories")
dataProvider.getOne({ resource: "categories", ... }); 

// specific getMany implementation (for "categories")
dataProvider.getMany({ resource: "categories", ... }); 

In this example all requests except for "posts" and "categories" are made through baseDataProvider. "posts" and "categories" resources use supabaseDataProvider. There is one exception: getMany method for "categories" resource goes through the user defined method.

Run tests

Jest tests are set up to run with npm test.




Package Sidebar


npm i data-provider-customizer

Weekly Downloads






Unpacked Size

30.4 kB

Total Files


Last publish


  • umutozdemir97