Welcome to the HDR UK Gateway Frontend, a Next.js React application that powers the user interface of the HDR UK Gateway. This application facilitates seamless interaction with the Gateway API using:
- fetch for efficient server-side communication.
- SWR for optimized client-side data fetching and state management.
- i18next for internationalization and multi-language support.
- Jest for unit and snapshot testing.
This project utilizes the App Router of Next.js, providing improved performance and flexibility over the traditional Pages Router.
Follow these steps to install and run the project on your local machine.
Ensure you have the following installed:
- Node.js (Latest LTS version recommended)
- npm or yarn (Package manager)
- Git (For cloning the repository)
Open a terminal and execute:
git clone https://github.com/HDRUK/gateway-web
cd gateway-web
Create a .env.local
file and populate it with appropriate values, using .env.example
as a reference.
Run the following command to install the required packages:
npm install
Once dependencies are installed, start the application using:
npm run dev
By default, the application will be available at http://localhost:3000.
In the project directory, you can run the following commands:
npm run dev
β Starts the development server.npm run build
β Builds the application for production.npm start
β Runs the compiled production build.npm run lint
β Runs ESLint to check for code quality issues.npm run lint:fix
β Runs ESLint to automatically fix simple lint issues.npm test
β Runs the Jest test suite.npm test:snapshot
β Runs the Jest test suite to update snapshots.
For a full list of scripts, run npm run
.
A brief overview of the project's folder structure:
βββ app/ # Next.js pages/api routes/actions
βββ components/ # Reusable React components
βββ config/ # Reusable configuration throughout the gateway
βββ const/ # Constant values
βββ hooks/ # React hooks
βββ interfaces/ # Types and interfaces
βββ modules/ # Module components
βββ pages/api # Legacy APIs that need adapting to App Router APIs
βββ providers/ # Provider Wrappers, such as SWR, Snackbars...
βββ public/ # Static assets (images, fonts, etc.)
βββ seeded/ # Any seeded data during the build process, such as sitemap
βββ services/ # Services and clients such as API calls
βββ styles/ # Global styles and theme settings
βββ types/ # Types and interfaces
βββ utils/ # Helper functions and utilities
βββ .env.local.example # Sample environment variables file
βββ next.config.js # Next.js configuration
βββ package.json # Project dependencies and scripts
βββ README.md # Project documentation
This project uses i18next for multilingual support, allowing for seamless language switching and localization. Translations are managed within the /src/config/messages/
directory and integrated using the i18next
library.
We use Jest for unit testing and React Testing Library for component testing. Snapshot testing is included to ensure UI consistency.
To run tests:
npm test
To update snapshots:
npm test:snapshot
- Next.js Documentation
- React Documentation
- SWR Documentation
- i18next Documentation
- Jest Documentation
- HDR UK Gateway API
For further support, please reach out via HDR UK or raise a bug or even better raise a PR!