Creating the project
This step consists in creating a standard React application without involving onekijs
.
This application looks exactly like the one proposed on the Angular site so you can compare the Angular and React versions.
Step Final result
The result of this step is as follows:
The code below is hosted on Code Sandbox.
Click the "Open Sandbox" button to view/edit the code with an online IDE.
- Vite App
- Nextjs App
Creating the project
We recommend to use Typescript instead of javascript. Therefore, all examples are in Typescript.
A onekijs
application is built with one of this build tool:
Type | Build tool | Librairies |
---|---|---|
Standard React app | Vite | OnekiJs, React, Redux, Immer, Saga, React Router Dom |
Next.js app | Create Next App | OnekiJs, React, Redux, Immer, Saga, Next, Next Router |
From then on, you benefit from all the advantages brought by this tool.
The code is slightly different depending on the framework used. Click on the corresponding tab to display the code corresponding to the type of application you want to build.
- Vite App
- Nextjs App
Vite is the most popular tool to boostrap a React project.
To create a projet named mystore-app, enter the following command:
// npm install -g yarn
yarn create vite mystore-app --template react-ts
Create next app is the tool to boostrap a Next.js project.
To create a projet named mystore-app, enter the following command:
// npm install -g yarn
yarn create next-app --typescript
Structure
Even if the project is very simple at this stage, we already structure the project as recommended in this chapter.
- Vite App
- Nextjs App
loading...
loading...
Via a command line enter:
cd mystore-app
yarn start
loading...
loading...
Via a command line enter:
cd mystore-app
yarn dev
to start a livereload webserver. The website is available at http://localhost:3000
Any change to the source code will refresh the page to reflect the change.
Next step
In the next step, we will transform this standard React application into an onekijs
application and add the ability to navigate between pages.