PWA(Progressive Web Apps) in NEXT JS
FrontendNextjs

PWA(Progressive Web Apps) in NEXT JS

2022-07-031μˆ˜μ •

🧐 μ‚¬μš©

install

npm install next-pwa

next js둜 λ§Œλ“€μ–΄μ§„ ν”„λ‘œμ νŠΈκ°€ μžˆλ‹€λŠ” κ°€μ •ν•˜μ— μ„€μΉ˜ν•΄μ€λ‹ˆλ‹€.

next.config.js

const withPWA = require('next-pwa');

const nextConfig = {
  pwa: {
    dest: 'public',
  },
  ...
};

module.exports = withPWA(nextConfig);

ν•΄λ‹Ή νŒŒμΌμ— pwa에 κ΄€ν•œ 섀정을 μΆ”κ°€ν•΄μ€λ‹ˆλ‹€.

manifest.json

[PWA Manifest Generator | SimiCart](https://www.simicart.com/manifest-generator.html/)

Favicon & App Icon Generator

manifest.json μ˜ˆμ‹œ

μ•± μ„€μΉ˜ μ‹œ 보이게 될 μ•„μ΄μ½˜κ³Ό 제λͺ© 등을 ν‘œμ‹œν•  μ •μ˜ ν•΄μ€λ‹ˆλ‹€.

next head

<Head>
    <meta
        name="viewport"
        content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"
    />
    <meta name="description" content="Description" />
    <meta name="keywords" content="Keywords" />
    <link rel="manifest" href="/manifest.json" />
    <meta name="theme-color" content="#317EFB" />
</Head>

이전에 λ§Œλ“€μ–΄λ‘” manifest νŒŒμΌμ„ λΆˆλŸ¬μ™€μ€λ‹ˆλ‹€.

크둬 μ£Όμ†Œμ°½μ˜ PWA μ„€μΉ˜ μ•„μ΄μ½˜

ν¬λ‘¬μ—μ„œ κ³΅μœ ν•˜κΈ° μ™Όμͺ½μ— μƒˆλ‘œμš΄ μ•„μ΄μ½˜μ΄ 생기면 μ„±κ³΅μž…λ‹ˆλ‹€.

πŸ€” 생각

μ΅œκ·Όμ—” λΈŒλΌμš°μ €μ—μ„œ 마이크, 카메라, 파일, λΈ”λ£¨νˆ¬μŠ€ λ“±λ“± 이 μ ‘κ·Ό κ°€λŠ₯ν•œ μƒν™©μ—μ„œ 웹을 μ•±μœΌλ‘œ μ„€μΉ˜ν•˜μ—¬ μ‚¬μš©ν•œλ‹€λŠ” 것은 앱이 μ—†λŠ” μ„œλΉ„μŠ€λ₯Ό 자주 μ΄μš©ν•˜λŠ” 상황에 적합할 것 κ°™λ‹€λŠ” 생각이 λ“­λ‹ˆλ‹€.

특히 ꡬ글과 μ• ν”Œμ˜ 인앱 결제 κ°•μ œκ°€ μš”κ΅¬λ˜λŠ” μƒν™©μ—μ„œ μœ λ¦¬ν•œ 건가 μ‹ΆμŠ΅λ‹ˆλ‹€.

ν•˜μ§€λ§Œ 웹이긴 μ›Ήμ΄λΌμ„œ 캐싱 이외에 미리 데이터λ₯Ό μ„€μΉ˜ν•΄λ‘” μƒνƒœμ—μ„œ μ‚¬μš©ν•˜μ§€λŠ” λͺ»ν•˜λ‹ˆ 단점도 λΆ„λͺ…ν•œ 것 κ°™μŠ΅λ‹ˆλ‹€.

λ”± μ•± μ„œλΉ„μŠ€κ°€ μ—†μœΌλ©΄μ„œ MAUκ°€ 높은 μ„œλΉ„μŠ€μ—μ„œ μ‚¬μš©ν•˜λ©΄ 큰 이읡이 될 수 μžˆμ„ 것 κ°™μŠ΅λ‹ˆλ‹€.

μ°Έκ³ : https://github.com/vercel/next.js/tree/canary/examples/progressive-web-app