Can I use TanStack Query in a Node.js framework, but without a provider?
I have a project that is used by other projects. Its basically a framework for providing wrapper functionality so you can plug and play CMS, Ecommerce backends, CRMS, etc.
I can definitely use TanStack Query on the front-end of those projects, as I can wrap in a ClientQueryProvider. Can I use it somehow in this framework without one?
3 Replies
rival-blackOP•17mo ago
For example, I have a hook in my project that is exported and can be used in a front-end.
useProduct() {}
This hook would call an api eventually. I would like to just implement TanStack Query on my base library, instead of having to integrate on every single front-end that uses my library. idk if that makes sense
rival-blackOP•17mo ago
basically something like this

rival-blackOP•17mo ago
This is a monorepo, I see there are some more github issues with some similar stuff, currently investigating.
I did have to add some stuff to my webpack in nextjs. Tho I'm not 100% sure I understand.
module.exports = withBundleAnalyzer({
i18n,
output: 'standalone',
webpack: (config, options) => {
if (options.isServer) {
config.externals = ["@tanstack/react-query","@tanstack/react-query-devtools", ...config.externals];
}
const reactQuery = path.resolve(require.resolve("@tanstack/react-query"));
const reactQueryDt = path.resolve(require.resolve("@tanstack/react-query-devtools"));
config.resolve.alias["@tanstack/react-query"] = reactQuery;
config.resolve.alias["@tanstack/react-query-devtools"] = reactQueryDt;
return config;
},
});