Skip to content
This repository has been archived by the owner on Jan 28, 2025. It is now read-only.

Feature: Dynamic Route Segments Support #105

Closed
danielcondemarin opened this issue Jul 16, 2019 · 4 comments
Closed

Feature: Dynamic Route Segments Support #105

danielcondemarin opened this issue Jul 16, 2019 · 4 comments
Labels
enhancement New feature or request nextjs 9.0

Comments

@danielcondemarin
Copy link
Contributor

Motivation

Nextjs 9 introduced Dynamic Route segments as per this RFC.

What does this mean for this serverless plugin?

This is great news for local development when using this plugin. Currently, when you have custom page routes you can't develop / test this locally, or at least properly, since the current serverless offline support is too limited. With dynamic routes support the users should be able to just run next dev and benefit from the development experience next provides, then is the plugin's job to provide feature parity when deploying onto AWS Lambda.

Proposal

Given the following app:

pages/
├── [root].js
├── blog/
│ └── [id].js
├── customers/
│ ├── [customer]/
│ │ ├── [post].js
│ │ ├── index.js
│ │ └── profile.js
│ ├── index.js
│ └── new.js
├── index.js
└── terms.js

The plugin will automatically produce the following serverless page functions:

# [root.js]
path: /{root}
request:
  parameters:
    paths:
      root: true
# blog/[id].js
path: blog/{id}
request:
  parameters:
    paths:
      id: true
# customers/[customer]/[post].js
path: customers/{customer}/{post}.js
request:
  parameters:
    paths:
      customer: true
      post: true
# customers/[customer]/index.js
path: customers/{customer}
request:
  parameters:
    paths:
      customer: true
# customers/[customer]/profile.js
path: customers/{customer}/profile
request:
  parameters:
    paths:
      customer: true
# customers/index.js
path: customers
# customers/new.js
path: customers/new
# index.js
path: /
# terms.js
path: /terms

The option to provide custom page routes will be kept, but it is recommended you use next dynamic routes whenever possible instead.

@Vadorequest
Copy link

Really interested in this. Especially if it increases DX by allowing to test our code locally the same way it runs against AWS. Env reproduction is a tough part, there are many implementations of aws lambda + next out there, but very few that have a good-enough DX for a production use case.

@romainquellec
Copy link

👍

@dennisrjohn
Copy link

Is there a timeline on adding this support? I've been using next.js 9.0 with this plugin and all has been well, until I needed to add a dynamic route.

I'd be happy to fork and add this in if someone could give me an idea of where to look in the codebase. I'd like to get this implemented as quickly as possible.

@danielcondemarin
Copy link
Contributor Author

For next 9 support use the newly released component 🙏 https://github.com/danielcondemarin/serverless-next.js

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request nextjs 9.0
Projects
None yet
Development

No branches or pull requests

4 participants