Deployment

Recipes

200 OK status code

Use Harp’s 200 file to route a client side app.

Why

If you’re writing a client-side application using a framework like Backbone, Angular, or Ember, you’ll want to do your routing client-side, using HTML5 PushState. The 200 file lets you provide a 200 OK status code

Usage

Replace your 404 file with a 200.jade, 200.ejs or 200.md file to get started. This file must be in the root directory of your application.

Example

Given the following directory strucutre:

myproject/
|- 200.ejs
|- app.js
|- framework.js
+- main.scss

The 200.ejs file will be served after all static routes and just before a 404 is found, allowing you to do any routing on the client side.

This works great in conjunction with static pages. For example, if you had a client side app but wanted your blog to be static and not use the router, your application might look like this: