[Next.js] Next.js 13.5 update!

๐Ÿ“„ Next.js 13.5 realize!

Next.js 13.5 ๋ฒ„์ „์ด ๋ฆด๋ฆฌ์ฆˆ ๋˜์—ˆ๋‹ค.

์–ด๋–ค ๊ธฐ๋Šฅ์ด ํ–ฅ์ƒ๋˜์—ˆ๋Š”์ง€ ํ™•์ธ ๊ฒธ ์ •๋ฆฌํ•œ๋‹ค.

1. ์‹œ์ž‘ ๋ฐ ์ƒˆ๋กœ๊ณ ์นจ ์‹œ๊ฐ„ ๋‹จ์ถ•

  • ๋กœ์ปฌ ์„œ๋ฒ„ ์‹œ์ž‘ ์‹œ๊ฐ„ 22% ๋‹จ์ถ•
  • HMR ์‹œ๊ฐ„ 29% ๋‹จ์ถ•
  • ๋ฉ”๋ชจ๋ฆฌ ์‚ฌ์šฉ๋Ÿ‰ 40% ๊ฐ์†Œ

๐Ÿ’ก HMR(Hot Module Replacement)? ๋ธŒ๋ผ์šฐ์ €๋ฅผ ์ƒˆ๋กœ๊ณ ์นจํ•˜์ง€ ์•Š์•„๋„ Webpack์œผ๋กœ ๋นŒ๋“œํ•œ ๊ฒฐ๊ณผ๋ฌผ์ด ์›น ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์— ์‹ค์‹œ๊ฐ„์œผ๋กœ ๋ฐ˜์˜

2. next/image ๊ธฐ๋Šฅ ํ–ฅ์ƒ

  • unstable_getImgProps ํ•จ์ˆ˜ ์ถ”๊ฐ€

๊ธฐ์กด์— next/image ๋ฅผ ์‚ฌ์šฉํ•˜๋ ค๋ฉด <Image> ์ปดํฌ๋„ŒํŠธ๋ฅผ ์‚ฌ์šฉํ•ด์•ผํ–ˆ๋‹ค. ์ด๋ฒˆ ์—…๋ฐ์ดํŠธ ๋ฒ„์ „์— ๋”ฐ๋ฅด๋ฉด <Image> ์ปดํฌ๋„ŒํŠธ๋ฅผ ์‚ฌ์šฉํ•˜์ง€ ์•Š์•„๋„, ์ด๋ฏธ์ง€๋ฅผ ๋ Œ๋”๋ง ํ•  ์ˆ˜ ์žˆ๋‹ค.

import { unstable_getImgProps as getImgProps } from "next/image";

export default function Page() {
  const common = { alt: "Hero", width: 800, height: 400 };
  const {
    props: { srcSet: dark },
  } = getImgProps({ ...common, src: "/dark.png" });
  const {
    props: { srcSet: light, ...rest },
  } = getImgProps({ ...common, src: "/light.png" });

  return (
    <picture>
      <source media="(prefers-color-scheme: dark)" srcSet={dark} />
      <source media="(prefers-color-scheme: light)" srcSet={light} />
      <img {...rest} />
    </picture>
  );
}

์ด ์™ธ์—๋„ Import ์ตœ์ ํ™” ๋“ฑ ์ž์ž˜ํ•œ ์—…๋ฐ์ดํŠธ ์‚ฌํ•ญ์ด ์žˆ์ง€๋งŒ, ์ด ๋‘๊ฐ€์ง€๊ฐ€ ๊ฐ€์žฅ ํฌ๊ฒŒ ๋ˆˆ์— ๋“ค์–ด์™”๋‹ค.

๋” ํ™•์‹คํ•œ๊ฑด vercel์ด page ๋ผ์šฐํŒ… ๋ณด๋‹ค app ๋ผ์šฐํŒ…์— ์ค‘์ ์„ ๋‘๊ณ  ์—…๋ฐ์ดํŠธ๋ฅผ ์ง„ํ–‰ํ–ˆ๋‹ค๋Š” ๋Š๋‚Œ์„ ๋ฐ›์•˜๋‹ค.

app ๋ผ์šฐํŒ…์˜ ์‚ฌ์šฉ๋Ÿ‰๋„ ์ ์  ๋Š˜๊ณ  ์žˆ๋Š”๋งŒํผ app ๋ผ์šฐํŒ… ๊ธฐ๋Šฅ์„ ์ž˜ ํ™œ์šฉํ•  ์ˆ˜ ์žˆ๋„๋ก ๊พธ์ค€ํžˆ ์‚ฌ์šฉํ•ด ๋ณด์•„์•ผ๊ฒ ๋‹ค.

์ฐธ๊ณ 

Leave a comment