Why the recommendation for a single API slice per app? #5176
-
|
Our app is very large and we have a lot of different endpoints. One idea that's been suggested is to have a different API slice per "domain object" in the API. However, I see many times the strong recommendation to only have a single API slice for the whole app, or at least for a given base URL. I am trying to understand this recommendation a little better. Is there a disadvantage to splitting up into multiple API slices? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
As covered in our docs ( https://redux-toolkit.js.org/rtk-query/api/createApi ):
Splitting endpoints should provide all the same conceptual / structural benefits of having multiple separate API instances, but with less overhead. The only potential issue is name collision. That's a case where it is up to you to make sure each endpoint name is unique. (There's been some requests for some sort of namespace prefixing, and it's not something we've tried to look into yet.) |
Beta Was this translation helpful? Give feedback.
As covered in our docs ( https://redux-toolkit.js.org/rtk-query/api/createApi ):