Where to enable it, and the quality setting nobody tunes
Brotli is a server or CDN setting, not a code change. Most CDNs enable it by default; origin servers frequently do not, which is why a site can be compressed at the edge and uncompressed for anything that bypasses the cache.
The setting worth knowing is the quality level, 0 to 11. Level 11 gives the smallest files and is slow enough that it is only appropriate for static assets compressed once at build time. For content generated per request, level 4 or 5 gives most of the benefit at a fraction of the CPU — and a server configured at 11 for dynamic responses can spend more time compressing than it saves in transfer.
Static assets should be pre-compressed at build and served from disk. Then you get level 11 with no runtime cost at all.