How do I integrate Prerender with Hapi.js?
Serve fully rendered HTML to AI crawlers and search engines from your Hapi.js server using the hapi-prerender community plugin.
TL;DR
The hapi-prerender plugin routes crawler requests from your Hapi.js server through Prerender, so AI crawlers and search engines receive fully rendered HTML while your website visitors still get the regular JavaScript app. Install the plugin, register it with your Prerender token, and verify the integration with a curl request — most setups take under 15 minutes.
⚠️ Thehapi-prerenderplugin is community-maintained, not built or supported by Prerender. Prerender provides this integration guide, but the plugin itself is maintained by its open-source authors at wrangr/hapi-prerender. Issues with the plugin code should be raised in the GitHub repository.
Why this matters
Hapi.js apps that render content with JavaScript on the client face the same problem as any single-page application: AI crawlers like GPTBot, ClaudeBot, and Googlebot may miss or misread your content because they see a JavaScript shell instead of your full page.
Prerender solves this by intercepting crawler requests at your Hapi server, returning cached HTML to bots, and leaving requests from your website visitors untouched.
Step 1: Create your Prerender account
If you don't already have one, sign up at prerender.io. You'll need an active account to generate the token used in Step 3.
Step 2: Confirm your Hapi.js version
The hapi-prerender plugin supports specific Hapi.js versions listed in the plugin's README. Open your package.json and check your current Hapi version against the compatibility notes at github.com/wrangr/hapi-prerender.
ℹ️ If your Hapi version isn't supported, upgrade Hapi before installing the plugin — registering an incompatible plugin will throw errors at server start.
Step 3: Copy your Prerender token
Open your Prerender dashboard, go to your account settings, and copy your Prerender token. You'll pass this token to the plugin in the next step.
Step 4: Install the hapi-prerender plugin
In your project root, run:
npm install hapi-prerender
This pulls the community plugin into your node_modules and adds it to your package.json dependencies.
Step 5: Register the plugin with your Hapi server
Add the plugin to your Hapi server setup and pass your Prerender token. The exact registration syntax depends on your Hapi version — follow the example in the plugin's README and replace the example token with your own.
Use YOUR_TOKEN as a placeholder in your codebase if you store the real token in an environment variable, which is the recommended pattern.
ℹ️ Not sure how to wire this into your existing Hapi setup? Ask Nexus, your AI integration assistant inside your Prerender dashboard — share yourserver.jssnippet and Nexus will walk you through registration and token handling.
Step 6: Restart your Hapi server
Restart your server so the new plugin loads. If the server starts cleanly with no plugin errors in the console, the integration is registered.
Step 7: Verify your integration is working
Test your integration by sending a request with a crawler user agent. Replace www.yourpage.com with your real domain:
curl -v -A googlebot www.yourpage.com/
Look for Prerender response headers in the output (for example, x-prerender-*). For the full verification walkthrough — including checking your dashboard for cached pages — see How to test your site after integration.
✅ Your integration is working when thecurlresponse contains Prerender headers and your dashboard shows cached pages within 2–5 minutes of the first crawler request.
If verification fails or you see a "Prerender Integration Not Detected" message, see What should I do if I receive a Prerender Integration Not Detected error?
💬 Still need help?If you have questions about setting up Prerender on Hapi.js or interpreting your verification results, our support team can help.→ Contact us at support@prerender.ioTo help us resolve your issue quickly, include any error messages, the steps you've already tried, and screenshots of your dashboard or terminal output.