cache-control max-age 1

[Next.js] SSR ํŽ˜์ด์ง€์—์„œ session pre-fetch ํ•˜๊ธฐ (next-auth)

ํ˜„์žฌ(2023.04.30) Next.js ํ”„๋ ˆ์ž„์›Œํฌ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋ธ”๋กœ๊ทธ๋ฅผ ๊ฐœ๋ฐœ ์ค‘์— ์žˆ์Šต๋‹ˆ๋‹ค. ๋ธ”๋กœ๊ทธ์—์„œ์˜ ์‚ฌ์šฉ์ž ์ธ์ฆ์€ next-auth ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋กœ ๊ตฌํ˜„ํ–ˆ์Šต๋‹ˆ๋‹ค. next-auth ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ์—์„œ ์ œ๊ณตํ•˜๋Š” NextAuth๋Š” ๋กœ๊ทธ์ธ ์‹œ signIn ๋ฉ”์†Œ๋“œ๋ฅผ ํ†ตํ•ด ์‚ฌ์šฉ์ž์˜ ์ •๋ณด๋ฅผ session์— ์ €์žฅํ•˜๊ธฐ ๋•Œ๋ฌธ์— ์‚ฌ์šฉ์ž์˜ ์ •๋ณด๋ฅผ ๊ฐ€์ ธ์˜ค๊ฑฐ๋‚˜ ๋กœ๊ทธ์ธ/๋กœ๊ทธ์•„์›ƒ ์ƒํƒœ๋ฅผ ํŒ๋ณ„ํ•  ๋•Œ session์„ ์‚ฌ์šฉํ•˜๋ฉด ํŽธ๋ฆฌํ•ฉ๋‹ˆ๋‹ค. ์ด๋ฒˆ ํฌ์ŠคํŠธ์—์„œ๋Š” Next.js ํŽ˜์ด์ง€์— ์ ์šฉํ•œ ๋ Œ๋”๋ง ๋ฐฉ์‹๊ณผ ๊ทธ ๋ Œ๋”๋ง ๋ฐฉ์‹์—์„œ session์„ pre-fetchํ•˜๋Š” ๋ฐฉ๋ฒ•์— ๋Œ€ํ•ด ์•Œ์•„ ๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. ๐Ÿ™‚ ๐ŸŒณ Why SSG -> SSR? Next.js ๊ณต์‹ ๋ฌธ์„œ์—์„œ๋Š” "์„ฑ๋Šฅ ์ƒ์˜ ์ด์œ ๋กœ ์„œ๋ฒ„ ์ธก ๋ Œ๋”๋ง์„ ํ†ตํ•œ ์ •์  ์ƒ์„ฑ ๋ฐฉ์‹์„ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์„ ๊ถŒ์žฅํ•œ๋‹ค. ์ •..

Next.js 2023.05.01
๋ฐ˜์‘ํ˜•