Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(docs): add docs for .svg unoptimized behavior #60735

Merged
merged 3 commits into from
Jan 16, 2024

Conversation

styfle
Copy link
Member

@styfle styfle commented Jan 16, 2024

@styfle styfle requested review from jh3y and StephDietz and removed request for a team January 16, 2024 19:46
docs/02-app/02-api-reference/01-components/image.mdx Outdated Show resolved Hide resolved
If you need to serve SVG images with the default Image Optimization API, you can set `dangerouslyAllowSVG` inside your `next.config.js`:
Therefore, we recommended using the [`unoptimized`](#unoptimized) prop when the [`src`](#src) prop is known to be SVG. This happens automatically when `src` ends with `".svg"`.

However, if you need to serve SVG images with the default Image Optimization API, you can set `dangerouslyAllowSVG` inside your `next.config.js`:
Copy link
Contributor

@delbaoliveira delbaoliveira Jan 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also mention the dangerouslyAllowSVG option in the images next.config.js page? https://nextjs.org/docs/app/api-reference/next-config-js/images

It would be good to mention all the keys for the images option on this page.

Copy link
Member Author

@styfle styfle Jan 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. I never understood why that page only has one config option.

Originally we had config as a separate page from props but I think @leerob or @atcastle consolidated them into a single page.

Do we want to split them out again?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feels like we just need stronger SVG guidance: shouldn't be used with next/image?

That removes the config option entirely.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are use cases where you might want svg to be cached and served from the same domain if the svg images are external urls. Although you can probably use rewrites for this.

I think the word "dangerous" in the property name is pretty good guidance already.

Regardless, that doesn't answer @delba's question/suggestion 😅

@styfle styfle merged commit 1886478 into canary Jan 16, 2024
30 checks passed
@styfle styfle deleted the fix-docs-clarify-svg-behavior branch January 16, 2024 20:06
@github-actions github-actions bot added the locked label Feb 1, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
created-by: Next.js team PRs by the Next.js team. locked
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants