This boilerplate provides a minimal setup to get React working in Vite with Capacitor and some ESLint rules to build a hybrid app.
- node >= 20.xx.xx
- npm >= 10.xx.xx
Install eslint and prettier extensions for your editor
npm i
- Start web version in development mode
npm run web
- Start mobile version in development mode
npm run mobile
- Build web version
npm run build-web
- Build mobile version
npm run build-mobile
- Run android app
npm run start-android
- Run ios app
npm run start-ios
src
├── core
│ ├── app
│ │ ├── components # common components
│ │ ├── containers # sections in page
│ │ ├── hooks # common hooks use in containers and pages
│ │ └── pages # pages for application
│ ├── assets
│ │ ├── fonts # fonts folder
│ │ ├── icons # icons components import from svg
│ │ ├── react.svg
│ │ └── svg # svg icons folder
│ ├── constants # constants folder
│ ├── locales
│ │ └── i18n.ts
│ ├── localstorage # data save in localstorage
│ ├── queries # query api wrapper
│ ├── routes # routes for application
│ ├── services # api functions
│ ├── store # global state
│ ├── styles
│ │ ├── GlobalStyles.tsx
│ │ ├── colors.ts # import colors from here
│ │ ├── fonts.d.ts
│ │ ├── global.module.css
│ │ └── text.ts # import common text style from here
│ ├── theme
│ │ └── index.ts
│ ├── types # type definitions
│ └── utils # utility functions
├── mobile
│ ├── configs
│ │ └── index.ts # import from .env file
│ ├── containers
│ ├── hooks
│ ├── index.html
│ ├── layouts
│ │ ├── DefaultLayout.tsx
│ │ └── index.tsx
│ ├── main.tsx # mobile's entry point
│ ├── pages
│ │ └── mobile
│ ├── routes
│ │ └── index.tsx
│ └── vite.config.ts
├── vite-env.d.ts
└── web
├── configs
│ └── index.ts
├── index.html
├── layouts
│ ├── DefaultLayout.tsx
│ └── index.tsx
├── main.tsx # web's entry point
├── pages
│ └── Web
├── routes
│ └── index.tsx
└── vite.config.ts
core
folder use to write commonscomponents
,containers
andpages
use for web and mobile.- Write
.env
inweb
andmobile
for each type of platform. - Write components which just related to ui only with no business logic to
core/app/components
. - Divide page in too different parts and write in
core/app/containers
if that page 's too complicated else just usecore/app/components
too avoid redundant code. - Write one function per file in
queries
,mutations
,services
,utils
,store
and export default those functions. - Avoid using any as much as posible and write types into
core/types
, each type will be seperated into different categries which are divided by folders and written in one file named after it's name. - Avoid creating sub folders for each react's component but try to create functions which others can use.
-
Using
var!
insteadvar as number
ifvar
has typenumber | undefined
-
Using
var?.<key>
as much as posible -
Using all camelCase, if some variables using other styles, try to convert to camelCase
-
Add space between JSX code and add comments if necessary to enhance readability.
-
Pay attention to mobile platform because UI can be different from web so try to test UI in mobile before pushing code.
-
Avoid using unnessary
<div>
tag by using<><>
-
Install a package by using exact version of it
-
Commit message following this format
<feat|fix|refactor>: [<id>] <message>