My first approach was to have everything in one app and decide to send different javascript/css to the client based on the platform. I did this via Iron:Router layout templates and CSS links in the different templates. The rendered function of the layout template would then load in additional javascript, based on the platform.
This works, but is convoluted and subverts some of the Meteor magic (all in one script, css compilation, etc).
Lately I have been checking into DDP.connect and have made some wonderful progress. Basically, you can write an app without the server and use the following code snippet to connect it to an existing app. In my case I connect the mobile version to the desktop version.
I just call this function at the beginning of my mobile app (not in Meteor.startup though)
connectToExistingBackend = function(url) {
//
// make a remote connection and set the global connection object to it
Meteor.connection = DDP.connect(url);
// make sure Accounts uses that connection
Accounts.connection = Meteor.connection;
//
// this is copied from ddp/*/web.browser/packages/ddp.js
// it makes sure all method calls are done with the correct connection
//
_.each(['subscribe', 'methods', 'call', 'apply', 'status', 'reconnect', // 52
'disconnect'], // 53
function (name) { // 54
Meteor[name] = _.bind(Meteor.connection[name], Meteor.connection); // 55
}); // 56
//
// we need re-declare the users collection so Meteor knows to use the remote one
//
Meteor.users = new Meteor.Collection('users');
//
// now that we have our act together, try to re-login
// unfortunately Accounts seems to have already run before
// we did the Meteor.connection = DDP.connect part, so we manually
// need to re-check the loginToken or hot code pushes log us out every time
//
var token = Accounts._storedLoginToken();
if(token)
{
Meteor.loginWithToken(token, function(err){
// this is going to throw error if we logged out
if(err) console.log(err);else console.log('loginWithToken');
});
}
}
With this little snippet I was able to write a mobile web.browser as well as web.cordova app and have all the Meteor magic.