π§Initial setup
Setup @codegouvfr/react-dsfr in your project or start from a template
If you already had the DSFR installed in your project, let's start from scratch:
Remove
@gouvfr/dsfrfrom your dependencies.Remove the import of
dsfr.css, dsfr.module.js the favicon and the fonts.Remove
the data-fr-scheme(anddata-fr-theme) attribude from your<html/>tag
And add this file to the root of your project, to enable pre & post scripts with pnpm:
When we say Yarn we usually refer to Yarn 1.x as most dev teams (Including me) havent upgraded to the newest version (for good reasons).
If you want to use Yarn Berry you be aware that pre- post- scripts aren't supported.
So you must do something like "dev": "copy-dsfr-to-public && next dev" (same thing for start)
Also you must configure it so it uses node_modules (sorry)
If you want a more complete starter with a Ready yo use stack that includes routing, autentication, internationalisation ect. you can also use this starter instead:
Add these three scripts to your package.json:
Trigger the execution of the postinstall script by running:
Add the following tags in the <head />
You're all set! Next step for you is to setup the integration with your routing library (react-router for example).
πIntegration with routing libsThe create-react-app project is no longer being maintained. If you are starting a new project you'll probably be beter off with Vite.
Add these three scripts to your package.json:
Trigger the execution of the postinstall script by running:
Add the following code in the <head />
You're all set! Next step for you is to setup de integration with your routing library (react-router for example)
πIntegration with routing libsYour framework isn't supported? Let's get in touch! Note: We don't have a custom integration for it but react-dsfr has been reported working with Gatsby.
Avoiding or flash of unstyled text (FOUT)
You can avoid having a flash of unstyled text by preloading the font variant used on your homepage (look in the network tab of your browser dev tools what are the font downloaded initially).
Add the following tags in the <head />
Add the following code in the <head />
Last updated
Was this helpful?
