1
votes

I have a meteor app that uses iron-router.

How do I make this meteor app create a fixed URL for sharing?

For example in jsfiddle.net, you start of in just jsfiddle.net PLAINLY.

However, after you type in the code, etc...and you decide you wanna share this with the world, you click on save. After you click on save, the link above changes to something like: jsfiddle.net/m9mfLn3p/. And now you can use jsfiddle.net/m9mfLn3p/ to share that page with that certain setting with the world....

How do I achieve something similar in my meteor app that uses iron-router?

Thank you very much.

1
I see there's a far more intricate answer, but if all you mean is share a single URL for a Meteor app, you simply need to go beyond running it locally (on localhost:3000 by default), and deploy it via "meteor deploy <appName>" After that, you can share <appName>.meteor.com I think it is. - B. Clay Shannon-B. Crow Raven
That's not what I meant...the answer below is much closer to the point...Thank you for sharing though - preston

1 Answers

2
votes

I have a similar pattern in my app. To solve this problem I have a collection that contains the data context that will be used by the route. Then I just create a document with the required data and use the _id of the document in that collection to create a url that can be reused.

Ex:

var id = Permalinks.insert(object); // object is the data I'll need later
var url = Meteor.absoluteUrl() + "myPath/" + id;
... share this url however - email, SMS, etc...

Then a route:

Router.route("/myPath/:id",{
  data: function(){
    return Permalinks.findOne({ _id: this.params.id });
  }
});