Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get current Route 'url' and 'as' info #1377

Closed
Filipvdb321 opened this issue Mar 9, 2017 · 6 comments
Closed

get current Route 'url' and 'as' info #1377

Filipvdb321 opened this issue Mar 9, 2017 · 6 comments
Assignees

Comments

@Filipvdb321
Copy link

Filipvdb321 commented Mar 9, 2017

I see that the Router has some properties: pathname, query, ....
Is it possible to expose a method to get the current 'url' and 'as' ?

That way you could for example save this in the state to navigate later to this location with Router.push(url,as);

Or is there already a better way to achieve this functionality?

@tpreusse
Copy link
Contributor

tpreusse commented Mar 10, 2017

Check out https://github.com/fridays/next-routes

Then you can reverse it with (url.pathname || Router.route).replace(/^\//, '') and (url.query || Router.query). url refers to the property that page components get and can be used while server rendering.

@arunoda
Copy link
Contributor

arunoda commented Mar 11, 2017

Currently it's not supported. Not exactly(or just only) these APIs. We should provide some ways to improve this.

This is one step towards that: #1345

@tpreusse
Copy link
Contributor

Also make sure to look at https://github.com/BDav24/next-url-prettifier

I think it would be great if something like next-routes api wise and next-url-prettifier feature set wise (multi language pretty urls) would be part of the core.

@matthewmueller
Copy link
Contributor

matthewmueller commented Apr 3, 2017

I'm also looking for a way to access as on the client-side. It seems like document.location.pathname and Router.router.as only gets updated after getInitialProps() has finished and the pathname passed in reflects the href value.

@Wolke
Copy link

Wolke commented Apr 20, 2017

I am looking,too

@arunoda
Copy link
Contributor

arunoda commented May 2, 2017

Gonna close this since I'm going to close this pretty close: #1843

@arunoda arunoda closed this as completed May 2, 2017
@lock lock bot locked as resolved and limited conversation to collaborators May 11, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants