A React application project bootstrapped
with create-next-app
.
Clone the repository here
Install the dependencies by running the following command
yarn.lock
file which will conflict with the package-lock.json
file.npm install
npm run start
or
yarn start
The project structure is as follows:
./
└── public
├── src
│ ├── api
│ ├── assets
│ ├── components
│ └── config
│ │ ├── i18n
│ │ └── routes
│ ├── guards
│ ├── helpers
│ ├── high-order-components
│ ├── hooks
│ ├── layout-components
│ ├── layouts
│ ├── lib
│ │ ├── bubbbly-balloon
│ │ ├── reduxoid
│ │ └── dicey-dialog
│ ├── mocks
| ├── redux
│ ├── pages
│ ├── sections
│ ├── seo
│ ├── store
| ├── user-portal
│ └──views
└── test
You can start editing the pages or add pages to the /src/pages/
.
Pages are automatically compiled and updated as you edit them.
Read more about the contents of the directories in contributing guide here to learn more about how to contribute to this project and the rules to follow.
The following are the core dependencies used in this project
We use GitHub Actions for pull request checks. Any pull request triggers checks such as linting, unit tests and E2E tests.
For lower level tests of utilities and individual components, we use jest
. We
have DOM-specific assertion helpers via
@testing-library/jest-dom
.
There are
5 questions every unit test must answer
and Eric Elliott created a testing
framework called RITEway that forces
you to write Readable, Isolated, and Explicit tests. The framework
only exposes a single assert
test function, which performs a deep equality
check.
This project uses ESLint for linting. That is configured in .eslintrc
with ignored files in .eslintignore
. You can
run the linter with yarn lint
or npm run lint
.
We use Prettier for auto-formatting in this project. The Prettier config is in .prettierrc
.
This project is deployed on AWS Amplify. The build settings are configured in amplify.yml
.
The production tip deployment is done on every push to the main
branch.
The staging tip deployment is done on every push to the staging
branch.
Special feature deployments can be done by pushing to the feature/<feature-name>
branch and setting
the feature/<feature-name>
branch as the deployment branch on AWS Amplify.
We use Sentry for error tracking. The Sentry DSN is configured in the next.config.js
file.
We use Google Analytics for analytics. The Google Analytics ID is configured in
the /src/config/firebase.js
file.
We use Firebase for authentication and push notifications. The firebase config is configured in the /src/config/firebase/
file. with
initialization in the /src/helpers/firebase.js
file.
Let's be honest, using next/image
is a pain. The opinions about forcing image widths and heights make it very
annoying.
We therefore use Sirv for image optimization. Using Sirv, we can serve images with the correct content type
and
optimized for web. Images are automatically compressed and resized to fit the device screen size.
The srcset
attribute is automatically added to serve different images to different devices. To use sirv images, in as
image tags in components,
use the SirvImage component in the /src/components/SirvImage
folder.
The SirvImage component takes the following
props:
src
: The image source (required)alt
: The image alt text (required)className
: The image class name (optional)width
: The image width (optional)height
: The image height (optional)role
: The image role (optional but required for accessibility if the file type is an SVG
)<SirvImage src={imageSrc} alt={imageAlt}/>
The sirv base url is configured in the APP_PATHS
object in /src/config/routes/index.js
file.
It can thus be used in other places in the app, programmatically to fetch images from sirv.
Next Image is not completely abandoned. It is still used for some images that are not hosted on sirv, and also more importantly, if we can supply all the required props to the image component.
To use next image, in as image tags in components, use the NextImage component in the /src/components/NextImage
folder. It wraps the next image component and takes the following props:
src
: The image source (required)alt
: The image alt text (required)className
: The image class name (optional)width
: The image width (optional)height
: The image height (optional)size
: The image size (optional), this is used to set the width and height of the image to the same valuerole
: The image role (optional but required for accessibility if the file type is an SVG
)layout
: The image layout (optional), this is used to set the layout of the image. It can be fill
, fixed
, intrinsic
, responsive
or none
. The default is responsive
priority
: The image priority (optional), this is used to set the priority of the image. It can be true
or false
. The default is false
quality
: The image quality (optional), this is used to set the quality of the image. It can be a number between 0
and 100
. The default is 75
loading
: The image loading (optional), this is used to set the loading of the image. It can be lazy
, eager
or auto
. The default is lazy
objectFit
: The image object fit (optional), this is used to set the object fit of the image. It can be fill
, contain
, cover
, none
or scale-down
. The default is cover
objectPosition
: The image object position (optional), this is used to set the object position of the image. It can be top
, top-right
, right
, bottom-right
, bottom
, bottom-left
, left
, top-left
or center
. The default is center
<NextImage src={imageSrc} alt={imageAlt}/>
To learn more about Next.js, take a look at the following resources:
You can check out the Next.js GitHub repository - your feedback and contributions are welcome!