I’m working on a project in React Native and want to connect to a Meteor server using a headless Meteor client (Meteor on the client without Blaze). I am well aware of Asteroid, which is fine, but I’d like to leverage Meteor itself, perhaps as a package. Something like:
myMeteor = require(‘meteor-app’)
// Someone indicate http://myawesomeapp.com as the location of my Meteor app
AwesomeCollection = myMeteor.AwesomeCollection
foo = myMeteor.Meteor.call(…)
AwesomeCollection might be a GroundDB collection or Collection2/SimpleSchema etc.
Any advise steering me in the right direction would be much appreciated. My initial thoughts are to use something like Demeteorize yet not totally clear on the details.
Another quick way to get meteor integrated with ReactNative or Titanium is to build an empty meteor app which will generate the necessary clientside js file. Create an npm package with the generated clientside js file. You will need to export the right properties from the clientside js file to be accessible in your ReactNative/Titanium app.
Hey @emmanuelbuah, that is a great suggestion and what I was thinking as well; yet how do we pass in the location of the Meteor server / Mongo to the client script from within the context of require? These are normally environment variables. (process.env.FOO = ‘value’; // won’t work on the client)
I’ve read many people mention utilizing the client bundle of Meteor, yet no pattern for this online. So perhaps my question is really this:
How do I pass in the environment variables Meteor’s client expects from within the context of it being included via require?
Your point about having to repeat the process is true; i’d automate it. There is another consideration that I’ve learn about as well. That web-sockets need to be polyfilled on both React Native and Native Script.