1

For those not familiar with the Meteor framework, when you navigate (e.g.) using the top nav, the page changes are almost instantaneous and do not result in the typical page-changing/page-load. Of course you could accomplish this in jQuery using .load(), but the thing about Meteor is that you could have a link on some other website to a specific page on your site, such as http://example.com/about and Meteor will take you directly to that page. This is good for SEO purposes.

My question:

If I'm not using Meteor, how can I accomplish this instant page-switch effect, and have the URL in the address bar change, and have each page fully linkable page (not http://example.com/#about). If I can keep it as simple as using HTML and jQuery, that would be great.

PS: If the solution involves using Apache or nginx rewrites, I'm okay with that.

MANOJ GOPI
  • 1,279
  • 10
  • 31
CaptSaltyJack
  • 15,283
  • 17
  • 70
  • 99

1 Answers1

0

Looks like you're building a single-page application. The part of an SPA that implements the linking functionality you describe is a "router", and with Meteor you've probably used iron:router.

What iron:router does is use the HTML5 pushState() API to manipulate the browser history and URL bar.

If you're new to web app development, you'll probably want a library that does that. You definitely do not want AngularJS (see why). However, it turns out that such no-hashtags routing libraries aren't that common... any reason not to use Meteor with iron:router?

Dan Dascalescu
  • 143,271
  • 52
  • 317
  • 404
  • Oops, and I just ran `yo angular --coffee` to start an Angular web app because I wanted pushState. :) – CaptSaltyJack Jan 31 '15 at 08:55
  • PS: Not new to web app development at all. – CaptSaltyJack Jan 31 '15 at 08:55
  • Would love to use Meteor, but my server is set up as a typical Apache server. No Node.js. – CaptSaltyJack Jan 31 '15 at 08:56
  • Node.js and Apache are orthogonal. BTW, [nginx is for 99% of the cases a much better alternative than Apache.](http://www.wikivs.com/wiki/apache_vs_nginx). Can you not [install Meteor](https://www.meteor.com/install)? What are you using for the backend, or are you using [no backend at all](https://unhosted.org)? – Dan Dascalescu Jan 31 '15 at 09:00
  • No, I have Meteor on my local Mac, and know how to develop apps with it. Actually, what the issue is is this: I've got a VPS running Apache (it HAS to run it, for now). I know I could probably run a Meteor site on some other port number, and maybe use Apache to reverse proxy to the Node.js port. I just have no clue how :) And no clue how to set up a Node.js server as a Debian service I can control with `sudo service [serviceName] start/stop`. Or I should say, have it start automatically when the server boots up (rc.d script) – CaptSaltyJack Jan 31 '15 at 09:02
  • I found this page. This actually helps. Now I just need to figure out how to make node boot my Meteor app up upon system startup. Shouldn't be too hard. http://stackoverflow.com/questions/17606340/how-to-deploy-a-meteor-application-to-my-own-server – CaptSaltyJack Jan 31 '15 at 09:08
  • Does Apache need to server port 80 on the same server? If so, you'll have to proxy_pass somehow. [For nginx, there's a ready-made Meteor config file on Meteorpedia.](http://www.meteorpedia.com/read/nginx). Alternatively, a DigitalOcean VPS starts at $5/mo and you can have a clean setup. – Dan Dascalescu Jan 31 '15 at 09:11
  • 1
    Yes, I've got a mission critical app on port 80 that needs Apache. But yeah, Apache has ProxyPass as well. This should actually be a piece of cake. Thanks for the motivation! :) I was getting into Angular, and *not* really liking it. – CaptSaltyJack Jan 31 '15 at 09:12
  • To keep Meteor -> node apps running indefinitely, I used [pm2 instead of forever](http://devo.ps/blog/goodbye-node-forever-hello-pm2/), and there's also [Meteor Up](https://github.com/arunoda/meteor-up). – Dan Dascalescu Jan 31 '15 at 09:13