fridays / next-routes

Universal dynamic routes for Next.js
MIT License
2.47k stars 230 forks source link

Query String Pattern Matching #273

Closed webberwang closed 1 year ago

webberwang commented 5 years ago

Can we do something like

pattern: '/page?action=create'

as opposed to

pattern: '/page/create`

because modals should be a child of the parent component in order to keep the background state, as opposed to creating its own route

elkwood commented 5 years ago

From the usage docs of path-to-regexp

Please note: The RegExp returned by path-to-regexp is intended for ordered data (e.g. pathnames, hostnames). It does not handle arbitrary data (e.g. query strings, URL fragments, JSON, etc).

The following are synonymous as I understand it


routes.add('page', '/page')
'/page?action=create'
'/page?action=delete'

routes.add('page', '/page/:action')
'/page/create`
'/page/delete`

const { action } = query
webberwang commented 5 years ago

@elkwood the 2nd approach :action creates a new route though