For the complete documentation index, see llms.txt. This page is also available as Markdown.

๐Ÿ”งInitial setup

Setup @codegouvfr/react-dsfr in your project or start from a template

And add this file to the root of your project, to enable pre & post scripts with pnpm:

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)

Demo setup in production here: https://react-dsfr-vite-demo.vercel.app/

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:

It's live here: https://vite-insee-starter.demo-domain.ovh/

Using Nx monorepo? See this.

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 libs

This documentation is for Next projects using the Page Router (aka the legacy next setup).

You are in this case if you have a pages/ directory at the root of your project.

Starter project in prod here: https://react-dsfr-next-demo.vercel.app/
See demo setup in production here: https://react-dsfr-cra-demo.vercel.app/

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 libs

Your 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?