How to use create-react-app to develop multiple pa

2020-06-16 02:49发布

When creating an app with create-react-app,there is only one index.html,does that means React can only handle one SPA at a time? What if I want to develop multiple pages? Should I create another SPA with create-react-app and then put them together after building each of them?

标签: reactjs
1条回答
家丑人穷心不美
2楼-- · 2020-06-16 03:31

Update:

Parceljs can do that. here is docs.

You can use Parcel instead of Webpack (which being used in create-react-app) and it provide you zero config environment to develop web apps (using react or anything else).


Having multiple pages (instead of SPA) is not what most React environments had in mind [before - see update above].

You can have different page URL's using react-router or similar client side routing solutions.

If the concern is bundle size, there are solutions using webpack or parcel to lazy load each bundle whenever they needed or cache bundle (using service workers) and so on (Tree shaking, ...). (check Code Splitting in React Docs)

Other concern I might have in my brain is SEO, in this case you may find Isomorphic app (react server side rendering) useful which initialize first view of requested URL HTML and sends it to client, then client will load react and react will take control of UI. This will help Google (or other search engines) find your URLs fast and user experience in transitions between pages will remain seamless.

查看更多
登录 后发表回答