Meta tags:
description= Note: this feature is available with react-scripts@0.5.0 and higher.;
Headings (most frequently used words):
the, public, folder, using, changing, html, adding, assets, outside, of, module, system, when, to, use,
Text of the page (most frequently used words):
the (30), you (20), #folder (13), and (13), #public (12), adding (10), this (9), use (8), files (8), for (7), will (7), react (6), assets (6), need (6), public_url (6), code (5), using (5), with (5), images (5), file (5), build (5), your (5), can (5), app (5), outside (4), html (4), note (4), that (4), add (4), script (4), include (4), fonts (4), stylesheets (4), create (4), github (3), get (3), when (3), module (3), system (3), page (3), reference (3), have (3), normally (3), javascript (3), content (3), errors (3), copy (3), process (3), instead (3), css (3), started (2), docs (2), changing (2), splitting (2), next (2), loading (2), graphql (2), global (2), variables (2), should (2), read (2), section (2), them (2), webpack (2), other (2), tag (2), like (2), bundled (2), their (2), recommend (2), from (2), number (2), result (2), filenames (2), hashes (2), time (2), missing (2), not (2), called (2), compilation (2), cause (2), 404 (2), users (2), post (2), processed (2), minified (2), img (2), env (2), src (2), import (2), getting (2), asset (2), escape (2), hatch (2), run (2), inside (2), there (2), into (2), scripts (2), example (2), copyright, 2025, facebook, inc, social, contributor, covenant, twitter, discussions, stack, overflow, community, learn, previous, last, updated, chaoshuai, 2022, edit, declares, topic, which, explains, how, some, libraries, may, incompatible, option, but, want, small, pace, thousands, dynamically, paths, specific, name, output, such, manifest, webmanifest, importing, useful, workaround, less, common, cases, won, query, arguments, rename, every, they, change, none, keep, mind, downsides, approach, logo, png, return, described, above, urls, used, sparingly, render, similar, purposes, substitute, correct, absolute, path, project, works, even, client, side, routing, host, non, root, url, npm, only, accessible, prefix, explicitly, specify, intention, make, part, node_modules, favicon, ico, href, icon, rel, link, index, put, copied, untouched, environment, variable, however, don, worry, about, browsers, caching, old, versions, together, avoid, extra, network, requests, encourage, see, sections, mechanism, provides, benefits, stylesheet, also, contains, tweak, compiled, added, automatically, during, set, title, feature, available, higher, support, advanced, usage, deployment, back, end, integration, testing, building, processing, reset, sass, modules, styles, development, welcome, search, help, deprecated, more, here, skip, main,
Text of the page (random words):
using the public folder create react app skip to main content create react app is deprecated read more here create react app docs help github search k welcome getting started development styles and assets adding stylesheets adding css modules adding sass stylesheets adding css reset post processing css adding images fonts and files loading graphql files using the public folder code splitting building your app testing back end integration deployment advanced usage support on this page using the public folder note this feature is available with react scripts 0 5 0 and higher changing the html the public folder contains the html file so you can tweak it for example to set the page title the script tag with the compiled code will be added to it automatically during the build process adding assets outside of the module system you can also add other assets to the public folder note that we normally encourage you to import assets in javascript files instead for example see the sections on adding a stylesheet and adding images and fonts this mechanism provides a number of benefits scripts and stylesheets get minified and bundled together to avoid extra network requests missing files cause compilation errors instead of 404 errors for your users result filenames include content hashes so you don t need to worry about browsers caching their old versions however there is an escape hatch that you can use to add an asset outside of the module system if you put a file into the public folder it will not be processed by webpack instead it will be copied into the build folder untouched to reference assets in the public folder you need to use an environment variable called public_url inside index html you can use it like this link rel icon href public_url favicon ico copy only files inside the public folder will be accessible by public_url prefix if you need to use a file from src or node_modules you ll have to copy it there to explicitly specify your intention to make this file a part of the build when you run npm run build create react app will substitute public_url with a correct absolute path so your project works even if you use client side routing or host it at a non root url in javascript code you can use process env public_url for similar purposes render note this is an escape hatch and should be used sparingly normally we recommend using import for getting asset urls as described in adding images and fonts above this section return img src process env public_url img logo png copy keep in mind the downsides of this approach none of the files in public folder get post processed or minified missing files will not be called at compilation time and will cause 404 errors for your users result filenames won t include content hashes so you ll need to add query arguments or rename them every time they change when to use the public folder normally we recommend importing stylesheets images and fonts from javascript the public folder is useful as a workaround for a number of less common cases you need a file with a specific name in the build output such as manifest webmanifest you have thousands of images and need to dynamically reference their paths you want to include a small script like pace js outside of the bundled code some libraries may be incompatible with webpack and you have no other option but to include it as a script tag note that if you add a script that declares global variables you should read the topic using global variables in the next section which explains how to reference them edit this page last updated on 6 17 2022 by chaoshuai lü previous loading graphql files next code splitting changing the html adding assets outside of the module system when to use the public folder docs get started learn react community stack overflow github discussions twitter contributor covenant social github copyright 2025 facebook inc
|