refinedev / refine

A React Framework for building internal tools, admin panels, dashboards & B2B apps with unmatched flexibility.
https://refine.dev
MIT License
28.68k stars 2.25k forks source link

[FEAT] Add a dataprovider using KY #6381

Open capsloq opened 1 month ago

capsloq commented 1 month ago

Is your feature request related to a problem? Please describe.

Most data providers use of Axios which is considered deprecated by (many/some). See adios-axios. Nowadays Native Fetch APIs are widely supported by all big browsers. A thin wrapper like KY provides an easy API to make use of functionalities like interceptors.

Describe alternatives you've considered

No response

Additional context

Axios was once a convenient library that utilized XMLHttpRequest in web browsers and the http module in Node environments. However, in today's modern development landscape, this approach has been surpassed by the native Fetch API, which offers consistent functionality across browsers, Node, and even other environments.

With the adoption of a unified API like Fetch, you can easily eliminate Axios as an additional dependency in your modern codebase, resulting in reduced bundle sizes. Moreover, the Fetch API has undergone full standardization, unlike Axios, which comes with its own set of nuances that often catch developers off-guard. This includes differences in how fetch and Axios handle promise rejection in various scenarios.

Furthermore, certain frameworks, like Next.js, have begun exposing additional features within the Fetch API that may not be readily accessible when using Axios.

Discussion was started here: https://github.com/refinedev/refine/discussions/6375#discussioncomment-10799548

Issue was opened for better tracking.

Describe the thing to improve

Add ky support @refinedev/simple-rest/ky Once the simple-rest-ky provider is implemented it might be used as a blueprint for upcoming providers e.g. Strapi 5

BatuhanW commented 1 month ago

@capsloq thanks for the issue. About exposing it as @refinedev/simple-rest/ky, you can check our nextjs-router package. We have @refinedev/nextjs-router/app and also @refinedev/nextjs-router/pages exports separately.

https://github.com/refinedev/refine/blob/master/packages/nextjs-router/package.json