[SOLVED] How can I reference local files from cloud functions?

Hi, I’m using custom hooks in my project. How can I reference them in my cloud functions? For example, I have a hook that calls a method in my smart contract.

Thank you.

Can you explain more in detail - what are you looking to do exactly? You want to have a cloud function call a hook (React hook?)?

Yes please. I’m wondering if its possible to import local scripts such as react hooks in cloud functions.

You want to have your cloud function use a hook or function that is local to your frontend or app? This would require something like an API/backend. I’m not sure what you’re looking to do here, what do you want to achieve exactly (in terms of end result)?

Yes please. I’m wondering if its possible to import local scripts such as react hooks in cloud functions.

Right now you can’t include libraries easily in cloud code - it’s a Node.js environment with access to the Moralis SDK and the Moralis server specific functions. Would be possible in the future if you can self-host Moralis servers. But even then, you wouldn’t use React (and React hooks).

1 Like

Thanks for the detailed explanation. I get it now. I just try to avoid duplication of code as much as I can and thought if I could easily reuse some functions from fronend on the cloud.

1 Like