Simorgh
BBC World Service News websites are rendered using Simorgh, a ReactJS based application. Simorgh also renders AMP news article pages for World Service and Public Service News.
Simorgh provides a fast and accessible web experience used by millions of people around the world each month (see list of websites using Simorgh). It is regularly maintained and well documented, and we welcome open source contributors.
Simorgh is primarily maintained by the BBC News Web Engineering teams. It delivers highly trusted news to readers all over the world, currently in (41 languages). We support a wide range of devices and care deeply about scale, performance, and accessibility. We work in agile, flexible teams, and have an exciting roadmap for future development.
Documentation index
Please familiarise yourself with our:
NB there is further documentation colocated with relevant code. The above list is an index of the top-level documentation of our repo.
Before Installation
Please read:
CONTRIBUTING.md
Installation
Install Node. https://nodejs.org/en/. We use the version specified in .nvmrc and if you have a node version manager (nvm) you can run the following script to automatically change to the project supported version.
Install Yarn
The Simorgh project uses Yarn for package management. It is recommended to install Yarn through the npm package manager, which comes bundled with Node.js when you install it on your system. To install Yarn, run this command:
npm install --global yarn
Then you can run the following commands to install Simorgh
git clone git@github.com:bbc/simorgh.git
cd simorgh
yarn install
Local Development
Export a relevant BFF_PATH so that simorgh can connect to the relevant fabl instance:
# For a local instance of fabl
export BFF_PATH="http://localhost:3210/module/simorgh-bff"
Start the application:
cd ws-nextjs-app
yarn dev
The nextJS application will start on http://localhost:7081.
Once the application is running, you can visit a valid route, e.g. http://localhost:7081/pidgin.
Secret Environment Variables
Some local-development commands used by BBC staff require additional environment variables that are not stored in this repository. BBC staff can follow this guide (requires access) to set them on your machine.
Feature toggles
Some features are hidden/shown based on feature toggles set remotely via BBC internal systems. By default when running the application locally however, these values are not fetched remotely and are set in these config files. As such, these may differ between environments. Please read the toggles documentation for more information and for instructions on how to fetch remote toggle values locally.
Article pages
Article pages are served at routes of the format /news/articles/:id where id is the asset ID generated by the Content Management System.
FYI: Article explaining the BBC's use of ids in URL
These two News articles are available on the Test environment of our CMS, as well as locally, so are often used for testing:
We are also serving AMP HTML pages at the route /news/articles/:id.amp https://www.ampproject.org
Services with variants can't be accessed using the format above, instead the variant must be provided in the URL.
Home pages
World Service home pages are served in the format /:service where service represents a World Service site:
Services with variants can't be accessed using the format above, instead the variant must be provided in the URL.
World Service home pages do not support AMP.
Topic Pages
Topic pages use internal BBC APIs that are not publicly accessible. This can cause the following warnings to appear when developing locally:
No BFF_PATH set as environment variable, you will not have access to topics
Internal developers who need to work on topic pages locally should contact the team for access. See Secret Environment Variables for how to set the required environment variables.
Other page types
You can find other pages types by looking through our routes and their associates regexes, but we suggest you start with the above then have a look at the core of the application to understand and find the other routes.
See a list of local route examples here.
Storybook (UI Development Environment/Style Guide)
We use Storybook for developing components in isolation from the Simorgh Application. You can access this at https://bbc.github.io/simorgh/
To run locally yarn storybook, it will then be available at http://localhost:9001/. Introduction to and documentation for Storybook is here: https://storybook.js.org/basics/introduction/.
When viewing Video stories locally, make sure to use a BBC domain, as outlined in the changing request location section. Video will not work in the hosted version of Storybook linked above for this reason.
We also use Chromatic QA to run cross-browser testing on our stories.
Storybook compiles JavaScript, TypeScript and JSX with SWC, configured in .storybook/main.ts. It uses Emotion's JSX runtime and SWC plugin.
When updating Storybook's SWC compiler or @swc/plugin-emotion, check their plugin compatibility and validate Emotion-styled stories as well as SCSS Modules and MDX documentation.
Please also note that if you would like to see the components rendered with our fonts, you will need to force a repaint of the canvas. This is because our fonts all have the font-display property of optional or swap in accordance with the respective loading strategies here: https://ws-downloads.files.bbci.co.uk/fonts/index.html. The easiest way to force a repaint is just to move the divider between the preview window the and Knobs section or resize the browser window.
Configuring the application to run on a local network
If you want to host the application to be accessible through your local network, follow the instructions here.
Production build locally
To run this application locally with a production build, run:
yarn build && yarn start.
We use yarn build locally which bundles the application pointing at localhost for data and static assets.
Using environment builds locally
This is mainly used for debugging latest using the TEST and LIVE environment bundles. Ensure that the bundles exist in the static asset location for the correct environment before starting to debug.
To run TEST bundles on localhost:
To run LIVE bundles on localhost:
Changing request location
Some features perform differently dependant on whether a user is located within the UK or internationally. You can explicitly request a specific version by accessing Simorgh via a specific localhost BBC domain:
If these urls do not work, you may need to add a hosts file entry (/etc/hosts or C:\Windows\System32\drivers\etc\hosts):
127.0.0.1 localhost.bbc.co.uk
127.0.0.1 localhost.bbc.com
Production build on CI
On deployment make buildCi is run in the CI environment which creates bundles for both the test and live environments. On the two environments the .env.test or .env.live files overwrite the .env file which is used to run the application with the correct bundles.
Bundle analysis reports
Every run of yarn build will update the bundle analysis files in the repo. To view a breakdown of the bundle size, open the generated html report in a browser ./reports/webpackBundleReport.html