Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use Prerenderio with Meteor?

I would like to use prerenderio with Meteor instead of phantomjs on the server with modulus.

However given the examples they provide, I'm not sure how to integrate it. They only provide a node express middleware which doesn't translate 100%.

like image 572
Daniel Fischer Avatar asked Oct 12 '14 07:10

Daniel Fischer


1 Answers

For SEO purposes? I mean, what else could it be? ;)

Firstly, remove the spiderable package if you haven't already.

Second, drop this at your server-side code (for example server/prerenderio.js):

// Use Prerender with your token
var prerenderio = Npm.require('prerender-node').set('prerenderToken', 'YOUR_TOKEN'); 
// Feed it to middleware! (app.use)
WebApp.connectHandlers.use(prerenderio);

If you're wondering about Npm.require (or Meteor.require), See this answer (by me, sorry for shameless plug) for the gist: https://stackoverflow.com/a/16481897/951773

Source: I've used prerenderio successfully for a couple of our clients.

![Good luck!][1]

EDIT:

Since there has been major differences now between express request and response objects to meteor's connect objects, it went to really complicated now. But this has been addressed now and hopefully the PR I put in works:

https://github.com/dfischer/meteor-prerenderio/issues/1

TL;DR Thanks to this question now we have a prerender.io meteor module.

like image 130
Seth Malaki Avatar answered Nov 16 '22 19:11

Seth Malaki