Here’s some common code in the Mantra sample blog:

import {Mongo} from ‘meteor/mongo’;

export const Posts = new Mongo.Collection(‘posts’);

export const Comments = new Mongo.Collection(‘comments’);

From: https://github.com/mantrajs/mantra-sample-blog-app/blob/master/lib/collections.js

You’d then go and import this code on both client and server. The aim is still to never duplicate code, both now and in 1.5 years from now. We just avoid using Meteor.isClient/isServer by sticking client only code in the client folder. Common code can be put in lib and then imported to either client or server files.

At first this wasn’t clear to me and I had the same questions, but now I think I understand what is supposed to be happening.

Written by

Founder: Skilled.co.il & Draft Fantasy. Full stack JavaScript Engineer. https://elie.tech

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store