Code Monkey home page Code Monkey logo

Comments (20)

beepboopitschloe avatar beepboopitschloe commented on April 28, 2024 54

@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.

arunoda avatar arunoda commented on April 28, 2024 30

I'm so happy to (and want to) move a lot of apps to next once we've dynamic routing.

from next.js.

arunoda avatar arunoda commented on April 28, 2024 23

Hey all, now we've support for custom routes.
See: https://github.com/zeit/next.js#custom-server-and-routing

from next.js.

dstreet avatar dstreet commented on April 28, 2024 22

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.

CreepGin avatar CreepGin commented on April 28, 2024 19

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.

impronunciable avatar impronunciable commented on April 28, 2024 8

@nodegin yes, it maps that way
screen shot 2016-10-25 at 7 40 59 pm

@nickdandakis It's not possible right now. It doesn't mean it won't be possible in the future.

from next.js.

rauchg avatar rauchg commented on April 28, 2024 1

@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.

trusktr avatar trusktr commented on April 28, 2024 1

@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.

nodegin avatar nodegin commented on April 28, 2024

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.

nkzawa avatar nkzawa commented on April 28, 2024

See also #25. It's the issue about custom server support which you can implement any routings.

from next.js.

dlindenkreuz avatar dlindenkreuz commented on April 28, 2024

Related: #91

from next.js.

dstreet avatar dstreet commented on April 28, 2024

@nmuth, I completely agree. Not sure why I didn't think of that at first.

from next.js.

sebasgarcep avatar sebasgarcep commented on April 28, 2024

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.

parkerproject avatar parkerproject commented on April 28, 2024

@sebasgarcep do you have an example or docs on how to use this?

from next.js.

sebasgarcep avatar sebasgarcep commented on April 28, 2024

@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.

rauchg avatar rauchg commented on April 28, 2024

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.

sebasgarcep avatar sebasgarcep commented on April 28, 2024

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.

sheerun avatar sheerun commented on April 28, 2024

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.

hariantara avatar hariantara commented on April 28, 2024

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.

fortil avatar fortil commented on April 28, 2024

if I want to export the routes to static files your solution (Custom server and Routing) works? @arunoda

from next.js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.