The Meteor Guide doesn’t specify the best place to put shared code and I wondered how people are currently doing this.
I just put mine in /lib
.
1 Like
/lib or /both
I prefer lib
As already mentioned, lib is the best place, since Meteor loads lib directory first. Not sure if that’s true for subfolders too (e.g. /client/lib, /server/lib and /both/lib)
When you are using Meteor 1.2 or lower, the code should be in /lib.
You can still put your shared code in /lib with Meteor 1.3 though that’s not the recommended way.
Preferred version is that you put your collections into /imports/api and export the collection so you can import the collection on the client and the server.
Check the todos application for an example: https://github.com/meteor/todos
1 Like