How to use create-react-app to develop multiple pages?

后端 未结 1 1049
一生所求
一生所求 2021-02-15 14:25

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

相关标签:
1条回答
  • 2021-02-15 15:17

    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.

    0 讨论(0)
提交回复
热议问题