Best Practices for Project Structure
I started using Convex 2 days ago and couldn't find any documentation on project structure.
I learnt that I have to use
"use node";
for files that contain actions that aren't in the root directory but then I wasn't sure if that's how I'm supposed to structure the project.
Am I overthinking this or am I missing something big? Would love some thoughts!
5 Replies
I learnt that I have to use "use node"; for files that contain actions that aren't in the root directoryThis doesn't sound accurate, you need to use
"use node"
if you want to use Node actions (https://docs.convex.dev/functions/runtimes#nodejs-runtime), the directory doesn't matterRuntimes | Convex Developer Hub
Convex functions can run in two runtimes:
We don't have official guidance on how to structure projects, but what you're doing looks good!
@Nicolas
I looked at the error again
And then I renamed the folder from
/actions
to /action
and it worked fine without use node;
.
Weird but it fixed it!Interesting, I didn't know about this legacy behavior! So yes this is something that we don't support anymore. But if you don't need the Node runtime feel free to do that!
I’ve removed it! Thank you!