ํ‹ฐ์Šคํ† ๋ฆฌ ๋ทฐ

๋ฐ˜์‘ํ˜•

๐ŸŽจ Next.js App Router์—์„œ ์ด๋ฏธ์ง€์™€ ํฐํŠธ ์ตœ์ ํ™” ์™„๋ฒฝ ๊ฐ€์ด๋“œ

Next.js๋Š” ํผํฌ๋จผ์Šค ์ค‘์‹ฌ์˜ ์›น ํ”„๋ ˆ์ž„์›Œํฌ๋‹ต๊ฒŒ, ์ด๋ฏธ์ง€์™€ ํฐํŠธ ๋ฆฌ์†Œ์Šค๋ฅผ ์ž๋™์œผ๋กœ ์ตœ์ ํ™”ํ•  ์ˆ˜ ์žˆ๋Š” ๊ธฐ๋Šฅ์„ ๊ธฐ๋ณธ์œผ๋กœ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค.
App Router ๊ธฐ๋ฐ˜ ํ”„๋กœ์ ํŠธ์—์„œ๋Š” next/image์™€ next/font ๋ชจ๋“ˆ์„ ํ†ตํ•ด ์†์‰ฝ๊ฒŒ ๋น ๋ฅด๊ณ  ๊น”๋”ํ•œ UI๋ฅผ ๊ตฌ์„ฑํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.


๐Ÿ–ผ๏ธ ์ด๋ฏธ์ง€ ์ตœ์ ํ™”: next/image ์‚ฌ์šฉ๋ฒ•

next/image๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์€ ๊ธฐ๋Šฅ์„ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค:

  • ์ง€์—ฐ ๋กœ๋”ฉ(Lazy Loading) ์ž๋™ ์ฒ˜๋ฆฌ
  • ์ด๋ฏธ์ง€ ํฌ๊ธฐ ์ž๋™ ์กฐ์ ˆ ๋ฐ ๋ฆฌ์‚ฌ์ด์ง•
  • WebP ๋“ฑ ์ตœ์‹  ํฌ๋งท ์ž๋™ ๋ณ€ํ™˜
  • ๋ ˆ์ด์•„์›ƒ ์‹œํ”„ํŠธ ๋ฐฉ์ง€

โœ… ๋กœ์ปฌ ์ด๋ฏธ์ง€ ์‚ฌ์šฉ

import Image from 'next/image';

export default function Profile() {
  return (
    <Image
      src="/profile.jpg" // public ๋””๋ ‰ํ† ๋ฆฌ ๊ธฐ์ค€
      alt="ํ”„๋กœํ•„"
      width={500}
      height={500}
      placeholder="blur"
    />
  );
}

๋˜๋Š” ์ด๋ฏธ์ง€ ํŒŒ์ผ์„ ์ง์ ‘ importํ•ด์„œ ์‚ฌ์šฉ:

import Image from 'next/image';
import profile from '../public/profile.jpg';

export default function Avatar() {
  return <Image src={profile} alt="์•„๋ฐ”ํƒ€" />;
}

๐ŸŒ ์™ธ๋ถ€ ์ด๋ฏธ์ง€(์›๊ฒฉ ์ด๋ฏธ์ง€) ์‚ฌ์šฉ

next.config.js์— ๋„๋ฉ”์ธ ๋“ฑ๋ก ํ•„์š”:

module.exports = {
  images: {
    remotePatterns: [
      {
        protocol: 'https',
        hostname: 'images.example.com',
      },
    ],
  },
};

์‚ฌ์šฉ ์˜ˆ์‹œ:

<Image
  src="https://images.example.com/image.jpg"
  alt="์›๊ฒฉ ์ด๋ฏธ์ง€"
  width={600}
  height={400}
/>

๐Ÿ…ฐ๏ธ ํฐํŠธ ์ตœ์ ํ™”: next/font ์‚ฌ์šฉ๋ฒ•

โœ… Google Fonts

๋นŒ๋“œ ์‹œ ๋‹ค์šด๋กœ๋“œ๋˜์–ด ์ž์ฒด ํ˜ธ์ŠคํŒ… ๋ฐฉ์‹์œผ๋กœ ์ ์šฉ๋˜๋ฏ€๋กœ ์„ฑ๋Šฅ๊ณผ ๋ณด์•ˆ์— ์œ ๋ฆฌํ•ฉ๋‹ˆ๋‹ค.

// app/layout.tsx
import { Inter } from 'next/font/google';

const inter = Inter({ subsets: ['latin'] });

export default function RootLayout({ children }) {
  return (
    <html lang="ko" className={inter.className}>
      <body>{children}</body>
    </html>
  );
}

โœ… ๋กœ์ปฌ ํฐํŠธ

๋ฐ˜์‘ํ˜•
// app/fonts.ts
import localFont from 'next/font/local';

export const pretendard = localFont({
  src: './fonts/Pretendard.woff2',
  display: 'swap',
});

import { pretendard } from './fonts';

export default function Text() {
  return <p className={pretendard.className}>๋กœ์ปฌ ํฐํŠธ ์ ์šฉ</p>;
}

๐ŸŽจ Tailwind CSS์™€ ํ•จ๊ป˜ ์‚ฌ์šฉ

ํฐํŠธ๋ฅผ CSS ๋ณ€์ˆ˜๋กœ ์ •์˜ํ•˜๊ณ  Tailwind ์„ค์ •์— ์—ฐ๋™ํ•ฉ๋‹ˆ๋‹ค.

// app/fonts.ts
import { Inter } from 'next/font/google';

export const inter = Inter({
  subsets: ['latin'],
  variable: '--font-inter',
});

// tailwind.config.js
module.exports = {
  theme: {
    extend: {
      fontFamily: {
        sans: ['var(--font-inter)', 'sans-serif'],
      },
    },
  },
};

// ์‚ฌ์šฉ ์˜ˆ์‹œ
<p className="font-sans">Tailwind๋กœ ์ ์šฉ๋œ ํฐํŠธ</p>

โœ… ์š”์•ฝ ์ •๋ฆฌ

ํ•ญ๋ชฉ ํ•ต์‹ฌ ๊ธฐ๋Šฅ ๋ชจ๋“ˆ
์ด๋ฏธ์ง€ ์ตœ์ ํ™” ์ง€์—ฐ ๋กœ๋”ฉ, ์ž๋™ ํฌ๊ธฐ ์กฐ์ ˆ, WebP ๋ณ€ํ™˜ next/image
๋กœ์ปฌ ์ด๋ฏธ์ง€ /public/์—์„œ ์‚ฌ์šฉ ๊ฐ€๋Šฅ import ๋˜๋Š” ๊ฒฝ๋กœ ์ง€์ •
์›๊ฒฉ ์ด๋ฏธ์ง€ ๋„๋ฉ”์ธ ๋“ฑ๋ก ํ›„ ์‚ฌ์šฉ next.config.js
Google Fonts ์ตœ์ ํ™” ์ž์ฒด ํ˜ธ์ŠคํŒ… ๋ฐฉ์‹ next/font/google
๋กœ์ปฌ ํฐํŠธ ์ ์šฉ ํ”„๋กœ์ ํŠธ ๋‚ด ํฐํŠธ ์ง์ ‘ ์‚ฌ์šฉ next/font/local
Tailwind ์—ฐ๋™ CSS ๋ณ€์ˆ˜๋กœ ํฐํŠธ ์ ์šฉ tailwind.config.js ์„ค์ •

 

Next.js, App Router, ์ด๋ฏธ์ง€ ์ตœ์ ํ™”, ํฐํŠธ ์ตœ์ ํ™”, next/image, next/font, ์›น ํผํฌ๋จผ์Šค, Google Fonts, ๋กœ์ปฌ ํฐํŠธ, Tailwind CSS

โ€ป ์ด ํฌ์ŠคํŒ…์€ ์ฟ ํŒก ํŒŒํŠธ๋„ˆ์Šค ํ™œ๋™์˜ ์ผํ™˜์œผ๋กœ, ์ด์— ๋”ฐ๋ฅธ ์ผ์ •์•ก์˜ ์ˆ˜์ˆ˜๋ฃŒ๋ฅผ ์ œ๊ณต๋ฐ›์Šต๋‹ˆ๋‹ค.
๊ณต์ง€์‚ฌํ•ญ
์ตœ๊ทผ์— ์˜ฌ๋ผ์˜จ ๊ธ€
์ตœ๊ทผ์— ๋‹ฌ๋ฆฐ ๋Œ“๊ธ€
Total
Today
Yesterday
๋งํฌ
ยซ   2025/05   ยป
์ผ ์›” ํ™” ์ˆ˜ ๋ชฉ ๊ธˆ ํ† 
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
๊ธ€ ๋ณด๊ด€ํ•จ
๋ฐ˜์‘ํ˜•