Comments (20)
@dstreet Personally, I think package.json
should only contain NPM configuration (i.e. dependencies, scripts, and metadata). I'd prefer using a next.conf.js
file for configuration specific to Next. Otherwise I like the idea 👍
from next.js.
I'm so happy to (and want to) move a lot of apps to next once we've dynamic routing.
from next.js.
Hey all, now we've support for custom routes.
See: https://github.com/zeit/next.js#custom-server-and-routing
from next.js.
I'm proposing a change where parameterized routes can be defined in package.json
. Mapping a parameterized route path to a specific file in the paths
directory:
{
"next": {
"routes": {
"/posts/:id": "posts/post",
"/posts/:id/comments": "posts/post/comments"
}
}
}
This implementation shouldn't interfere with existing routing logic. Parameters are also passed through the component props via params
.
Implementation:
dstreet@55d3173
from next.js.
Since zeit.co is built with next.js, do all their blog urls just map to static files???
https://zeit.co/blog/next
->/pages/blog/next.js
https://zeit.co/blog/now-certs
->/pages/blog/now-certs.js
Anyhow, I do believe the majority of non-trivial sites depend on some form of dynamic routing (route params). So this should be pretty high up there in the future todo list, right?
from next.js.
@nodegin yes, it maps that way
@nickdandakis It's not possible right now. It doesn't mean it won't be possible in the future.
from next.js.
@sebasgarcep also, we do plan on exposing low-level APIs (they have been picked and designed with that in mind), but when we played around with them, they ended up being really not ergonomic.
Furthermore, we found that app.render
covers the majority of use cases (like caching, fancy routing, etc) without requiring more than just the raw, low-level HTTP request / response objects.
from next.js.
@fortil, I think it does not work with static routes and that it requires a server. A static server wouldn't be able to replace an ID in the URL with static-served content (if it could then it wouldn't be a static server anymore).
What I mean is, if we have a URL /posts/some-post-from-a-database
, there's no way a static server could map that to a file that actually exists. The server is needed in a rider to fetch the data for the post and to serve content not based on the filesystem.
from next.js.
Similar question, what if I place a directory under /pages
?
e.g. /pages/test/profile.js
should mapping to /test/profile
etc.
from next.js.
See also #25. It's the issue about custom server support which you can implement any routings.
from next.js.
Related: #91
from next.js.
@nmuth, I completely agree. Not sure why I didn't think of that at first.
from next.js.
I have parametric routing working using the fantastic https://github.com/hapijs/call. It allows me to define all sorts of parametric routes. For example a /users/{name}.js
file will match to either of /users/tom
or /users/mark
without having to do any configuration. It is what HapiJS uses to do routing, so it's battle-tested.
from next.js.
@sebasgarcep do you have an example or docs on how to use this?
from next.js.
@arunoda I have some issues with the way custom routes work. Mainly that Next does not exposes its render methods and you have to pass it the raw request and response objects. Of course, that doesn't always plays nice with frameworks like Hapi when you want to embed Next.
@parkerproject If you're still interested you can email me.
from next.js.
Mainly that Next does not exposes its render methods and you have to pass it the raw request and response objects.
Requiring the raw request and response objects sounds like a good abstraction. Maybe Hapi should expose them, rather than us not require them?
from next.js.
They do expose them 😄, though it is not recommended to interact directly with them.
Anyways, thanks for the input. It's a great project you have here.
from next.js.
I've prepared with-extracted-stylesheet example with custom routes that fallback to appropriate pages in both development and production, even for dynamic urls like described here: #3451
from next.js.
how about this one. project 1 (SSR using next js) project 2 (the same), but project 1 front end call the project 2 server, how do i get the params in server of project 2 that url is rendered in project 1 on front end side?
from next.js.
if I want to export the routes to static files your solution (Custom server and Routing
) works? @arunoda
from next.js.
Related Issues (20)
- Docs:
- approuter app\default is ignored after build HOT 1
- app\default is ignored after build HOT 4
- Required AUTH_SECRET in latest version HOT 3
- Turbopack: "Cannot find module" when package `require()` a package installed via the `optionalDependencies` field in package.json HOT 1
- Invalid import alias being used in CLI (create-next-app)
- Parallel Routes not working as expected in the development HOT 3
- Jest/Vitest unit testing: TypeError: (0 , _reactdom.useFormStatus) is not a function HOT 1
- HookWebpackError in isInterceptionRouteRewrite() when rewrites has an empty `has` array
- unable to read cookie in a server action from client component call in chrome 56
- Bun and Turbopack print lots of warnings in v14.2.0-canary.48 HOT 2
- Docs: `aria-disabled` does not disable button. HOT 6
- NextJS Caching based on Get URL and not Tag HOT 2
- Unable to parse config export in source file HOT 1
- Unable to parse config export in source file HOT 1
- Unable to parse config export in source file HOT 8
- next/link leads to a cached page HOT 1
- While Scrolling back to top in mobile, Next app Breaks! HOT 5
- headers() fails to opt route into dynamic rendering if generateStaticParams for all params is defined in layout
- Using Link/Router with 'shallow' to navigate from pages to app router, when there is a top-level dynamic route under pages, lands on the dynamic route instead
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from next.js.