Skip to main content
View plugin on GitHub
See starters using this

gatsby-plugin-express

version downloads

Server side client route matching, redirect and 404 handling

Usage

gatsby-config.js

plugins: [
  {
    resolve: 'gatsby-plugin-express',
    options: {
      output: 'config/gatsby-express.json',
    }
  }
]

express app

const gatsyExpress = require('gatsby-plugin-express');
const app = express();

// serve static files before gatsbyExpress
app.use(express.static('public/'));
app.use(gatsyExpress('config/gatsby-express.json', {
  publicDir: 'public/',
  template: 'public/404/index.html',

  // redirects all /path/ to /path
  // should be used with gatsby-plugin-remove-trailing-slashes
  redirectSlashes: true,
}));

Docs
Tutorials
Plugins
Blog
Showcase