localStorage e window só podem ser acessados via o client. Pelo vi que no seu código, você não colocou o "use client" no topo do arquivo que está usando essas ferramentas. Você pode tentar isso.
Além do mais, pelo que me lembro, no build da Vercel ele dá uma ideia aonde está o erro no código. Dá uma verificada lá pra ver.
Caso necessário adicione mais informações aqui.
Opa Thiagão, blz.
Valeu pelo direcionamento, eu estou usando o 'use client' somente no arquivo page.js, mas a implementação do localstorage e do windows.location está no arquivo service.js.
Devo usar o 'use client' no arquivo service.js também? Obs. A aplicação funciona localmente.
Está aqui o log do deploy que tentei fazer e aparentou erro.
[07:03:40.512] Running build in Washington, D.C., USA (East) – iad1
[07:03:40.625] Cloning github.com/tigocode/to-do (Branch: master, Commit: e2f73c6)
[07:03:40.837] Cloning completed: 214.685ms
[07:03:40.939] Previous build cache not available
[07:03:41.136] Running "vercel build"
[07:03:41.570] Vercel CLI 37.8.0
[07:03:41.943] Installing dependencies...
[07:03:48.726]
[07:03:48.726] added 23 packages in 7s
[07:03:48.727]
[07:03:48.727] 3 packages are looking for funding
[07:03:48.727] run npm fund
for details
[07:03:48.746] Detected Next.js version: 14.2.5
[07:03:48.748] Running "npm run build"
[07:03:48.894]
[07:03:48.894] > to-do@0.1.0 build
[07:03:48.894] > next build
[07:03:48.894]
[07:03:49.555] Attention: Next.js now collects completely anonymous telemetry regarding usage.
[07:03:49.555] This information is used to shape Next.js' roadmap and prioritize features.
[07:03:49.555] You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL:
[07:03:49.556] https://nextjs.org/telemetry
[07:03:49.556]
[07:03:49.621] ▲ Next.js 14.2.5
[07:03:49.621]
[07:03:49.700] Creating an optimized production build ...
[07:04:01.268] ✓ Compiled successfully
[07:04:01.268] Linting and checking validity of types ...
[07:04:01.395] Collecting page data ...
[07:04:02.469] Generating static pages (0/5) ...
[07:04:02.515] Generating static pages (1/5)
[07:04:02.691] Generating static pages (2/5)
[07:04:02.691] Generating static pages (3/5)
[07:04:02.692] ReferenceError: localStorage is not defined
[07:04:02.692] at T (/vercel/path0/.next/server/app/page.js:1:7825)
[07:04:02.692] at nt (/vercel/path0/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:38746)
[07:04:02.692] at Object.useState (/vercel/path0/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:40703)
[07:04:02.692] at t.useState (/vercel/path0/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:110091)
[07:04:02.692] at $ (/vercel/path0/.next/server/app/page.js:1:8191)
[07:04:02.692] at nj (/vercel/path0/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:46251)
[07:04:02.693] at nM (/vercel/path0/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:47571)
[07:04:02.693] at nN (/vercel/path0/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:64546)
[07:04:02.693] at nI (/vercel/path0/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:47010)
[07:04:02.693] at nM (/vercel/path0/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:47717) {
[07:04:02.693] digest: '3558331066'
[07:04:02.693] }
[07:04:02.693]
[07:04:02.693] Error occurred prerendering page "/". Read more: https://nextjs.org/docs/messages/prerender-error
[07:04:02.693]
[07:04:02.693] ReferenceError: localStorage is not defined
[07:04:02.693] at T (/vercel/path0/.next/server/app/page.js:1:7825)
[07:04:02.693] at nt (/vercel/path0/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:38746)
[07:04:02.693] at Object.useState (/vercel/path0/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:40703)
[07:04:02.693] at t.useState (/vercel/path0/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:110091)
[07:04:02.693] at $ (/vercel/path0/.next/server/app/page.js:1:8191)
[07:04:02.693] at nj (/vercel/path0/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:46251)
[07:04:02.693] at nM (/vercel/path0/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:47571)
[07:04:02.694] at nN (/vercel/path0/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:64546)
[07:04:02.694] at nI (/vercel/path0/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:47010)
[07:04:02.694] at nM (/vercel/path0/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:47717)
[07:04:02.930] ✓ Generating static pages (5/5)
[07:04:02.939]
[07:04:02.939] > Export encountered errors on following paths:
[07:04:02.939] /page: /
[07:04:02.971] Error: Command "npm run build" exited with 1
[07:04:03.125]