File tree Expand file tree Collapse file tree 2 files changed +35
-1
lines changed Expand file tree Collapse file tree 2 files changed +35
-1
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ pairing with smart people at Hashrocket.
1010
1111For a steady stream of TILs, [ sign up for my newsletter] ( https://tinyletter.com/jbranchaud ) .
1212
13- _ 1107 TILs and counting..._
13+ _ 1108 TILs and counting..._
1414
1515---
1616
@@ -490,6 +490,7 @@ _1107 TILs and counting..._
490490- [ Create Files And Directories For Dynamic Routes] ( nextjs/create-files-and-directories-for-dynamic-routes.md )
491491- [ Define URL Redirects In The Next Config] ( nextjs/define-url-redirects-in-the-next-config.md )
492492- [ Remove A Query Param From The URL] ( nextjs/remove-a-query-param-from-the-url.md )
493+ - [ Ship Public Assets With A Next.js App] ( nextjs/ship-public-assets-with-a-nextjs-app.md )
493494
494495### Phoenix
495496
Original file line number Diff line number Diff line change 1+ # Ship Public Assets With A Next.js App
2+
3+ A Next.js project includes a top-level ` public ` directory. Anything in this
4+ directory at build time will be publicly available.
5+
6+ This is handy for things like a logo, cover image, or favicon.
7+
8+ If I create an ` images ` directory in ` public ` and then place an SVG in it:
9+
10+ ``` bash
11+ $ ls public/images
12+ logo.svg
13+ ```
14+
15+ Then I can reference that image in the HTML or JSX of my app pages, such as in
16+ a ` header.jsx ` component.
17+
18+ ``` jsx
19+ const Header = () => {
20+ < div>
21+ {/* a bunch of header and nav content */ }
22+ < img className= " logo" src= " /images/logo.svg" / >
23+ < / div>
24+ }
25+ ```
26+
27+ Notice it is publicly available at ` /images/logo.svg ` .
28+
29+ You can do this with other files as well. For instance, some kind of company
30+ brochure PDF could be placed in ` public ` and you could link to it as a
31+ download.
32+
33+ [ source] ( https://nextjs.org/docs/basic-features/static-file-serving )
You can’t perform that action at this time.
0 commit comments