Socket
Socket
Sign inDemoInstall

next-nginx-routes

Package Overview
Dependencies
0
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    next-nginx-routes

Generate Nginx routing configuration for static Next.js projects.


Version published
Weekly downloads
5K
increased by83.16%
Maintainers
1
Created
Weekly downloads
 

Changelog

Source

1.2.1 (2023-11-03)

Bug Fixes

  • generate correct routes for trailingSlash config (d98e351)

Readme

Source

next-nginx-routes

Generate Nginx routes configuration file for Next.js static HMTL export, also known as output: export.

This dependency-free NPM package provides a NPM script to convert all your Next.js routes like:

{
  "page": "/[foo]",
  "regex": "^/([^/]+?)(?:/)?$",
  "routeKeys": { "foo": "foo" },
  "namedRegex": "^/(?<foo>[^/]+?)(?:/)?$"
}

... into Nginx routes like:

location ~ ^/([^/]+?)(?:/)?$ {
  try_files /[foo].html /index.html;
}

Note: currently only Next.js pages router is fully supported.

Getting started

Installation

yarn add --dev next-nginx-routes

Generate Nginx configuration file

Add next-nginx-routes to your build script:

{
  "build": "next build && next-nginx-routes"
}

And run Next.js export:

yarn run build

Include Nginx configuration file

Finally include the generated configuration file next-routes.conf in your Nginx site configuration file and make the Next.js out directory available to Nginx.

Requirements

More

  • See example folder for a minimal Docker example.
  • Read more about this approach in our blog post.

Keywords

FAQs

Last updated on 03 Nov 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc