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

hashbang support!? #601

Closed
antoinegrant opened this issue Dec 13, 2014 · 17 comments
Closed

hashbang support!? #601

antoinegrant opened this issue Dec 13, 2014 · 17 comments

Comments

@antoinegrant
Copy link

Did I miss something or there are no support for hashbang?

If it's not supported, is it planed to add the ability to chose to use a hashbang or a simple hash?

Thanks

@ryanzec
Copy link

ryanzec commented Dec 13, 2014

It is definitely supported (all the examples seem to run with hashbang mode). From the docs is seems like:

//push state mode
Router.run(routes, Router.HistoryLocation, function (Handler) {
  React.render(<Handler/>, el);
});

//hashbang mode
Router.run(routes, function (Handler) {
  React.render(<Handler/>, el);
});

@antoinegrant
Copy link
Author

@ryanzec When you make the reference to hashbang, are you referencing #! or #?

The app I'm building as to support the _escaped_fragment_ technic as described in this Google spec

Running the example provided in this repo we can observe that only the # is used, not the #!.

// hash mode
Router.run(routes, function (Handler) {
  React.render(<Handler/>, el);
});

// still hash mode
Router.run(routes, Router.HashLocation, function (Handler) {
  React.render(<Handler/>, el);
});

@ryanzec
Copy link

ryanzec commented Dec 13, 2014

Ah, I misunderstand, I was talking about just the #, not #!.

@antoinegrant
Copy link
Author

I have submitted a pull request #602 that enables the #! method. Altho, there are no tests for it so it's mostly just a way to kickstart the idea. I will use my fork in our project, so if I run into issues I will fix and resubmit a pull request.

@gpbl
Copy link

gpbl commented Dec 13, 2014

Am I the only one seeing that hashbang as bad practice? I never needed it.

@ryanzec
Copy link

ryanzec commented Dec 13, 2014

Depends on browser I think. I am in a lucky position where I only need to support IE 10+ (not many people are in that position). I am not sure at was IE version you need to use hashbangs.

@gpbl
Copy link

gpbl commented Dec 13, 2014

It's a trick for the google crawler, nothing to do with browsers. I'd definitely go with server rendering, but i understand it's not the easiest way...

@mjackson
Copy link
Member

Thankfully hashbang is no longer in widespread use. Even Google don't use it anymore on their domains. As @gpbl pointed out, they were only ever needed for the Google page crawler, not for browsers. Old versions of IE will work fine using HashLocation. For modern browsers, use HistoryLocation, and let Google crawl that.

@Feawel
Copy link

Feawel commented Aug 20, 2015

If definitely needed, you can use following stackoverflow answer http://stackoverflow.com/questions/25086832/how-to-stop-in-browser-with-react-router/32122395#32122395

@gpbl : one example where i needed it

  • front app with react on AWS s3 + cloudfront to allow max performance and no load problem
  • backend app only use as API endpoint
  • IE8 support :)

@kfuchs
Copy link

kfuchs commented Dec 16, 2015

Agreed with @Feawel, totally needed.

@heybenji
Copy link

+1 for hashbang and thusly Google crawler support in #602. Also has added benefit of making URLs shareable on Facebook. If #602 had tests written, would the maintainers consider that pull request... Or are @aliceriot and I barking up the wrong tree

@taion
Copy link
Contributor

taion commented Mar 16, 2016

If you want shareability and crawl-ability, you're going to need some sort of server-side support anyway, no? Facebook isn't going to request with the hash.

I'm not 100% opposed to adding this as a feature, maybe, but it seems like you're doing something that's quite contrary to modern best practices if you're trying to work that way.

@tvervest
Copy link

+1 on hashbang support.

Like @Feawel, I simply need the feature for legacy support as I'm working on a new front-end on top of a legacy API and I'm bound to S3. I understand that the better solution is to use server-side rendering etc, but that simply isn't an option in this project. It's an unfortunate reality, but not all companies can be as future-ready as facebook ;)

TL;DR: Because of the lack of hashbang support I can't use react-router, please fix!

@taion
Copy link
Contributor

taion commented Mar 18, 2016

If you want this feature, make an appropriate PR to history.

@tvervest
Copy link

PR #602 has already been rejected with this feature

@taion
Copy link
Contributor

taion commented Mar 18, 2016

#602 had no tests and also isn't merge-able any more.

@tvervest
Copy link

Small update for those who run into this issue on Amazon S3; the problem can be circumvented by specifying the main index.html as the error page. It's not a perfect solution, but it's a good enough workaround ;)

More details are available in this blog post.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 22, 2019
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

9 participants