简体   繁体   中英

Browser back/forward for single Page Applications?

I was working on a Single Page Application(SPA). So to maintain the browser back and forward functionality I am using htmlPushState and window.onpop passing the parameter to change css and call rest APIS from backend.

So currently my project has 5 pages under SPA, but I am bit concerned regarding the scalability.

If the project scales will it be difficult to manage back/forward browser clicks?

Are there any best practices to be followed for this? Is htmlPushState a good practice to follow?

PS: I am using reactjs in frontend(Is there any way in which I can use reactjs to handle browser back and forwards?)

Since you mentioned reactjs in your tags, I would highly suggest using React Router which supports HTML5 history API. React Router is essentially a wrapper around history package so you can use that as well, depending on your needs.

React Router is one of the most scalable solutions and it works really well in enterprise and consumer facing web sites.

React Router is a complete routing library for React . It has a simple API with powerful features like lazy code loading, dynamic route matching, and location transition handling built right in.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM