Skip to content

useI18nContext throws error on _payload.json requests with SWR/ISR routes and cold cache #3901

@draganpetos

Description

@draganpetos

Environment

  • Nuxt: 4.2.2
  • Nitro: 2.12.9
  • @nuxtjs/i18n: 10.2.1
  • Deployment: Netlify (SWR/ISR)
  • Node: 22.20.0

Reproduction

  1. Create a Nuxt 4 project with @nuxtjs/i18n
  2. Configure route rules with ISR/SWR
  3. Deploy to Netlify
  4. Navigate to any page - the _payload.json request fails with 500 error
  5. Refresh the page - it works (cache is now warm)

Describe the bug

When using the @nuxtj/i18n module with latest Nuxt version on Netlify (both locally and in production), _payload.json requests fail during ISR/SWR requests with cold cache:

H3Error: Nuxt I18n server context has not been set up yet.
at useI18nContext (file:///.netlify/functions-serve/.unzipped/server/chunks/nitro/nitro.mjs:7280:11)
at file:///.netlify/functions-serve/.unzipped/server/chunks/nitro/nitro.mjs:7630:17

This is a critical issue for production deployments using ISR/SWR with i18n, as it causes 500 errors on first page loads.

Additional context

  • Netlify local: Consistently on _payload.json requests
  • Netlify production: Only on first request with cold cache when using ISR/SWR routes
  • Nuxt dev: Does NOT occur
  • After refresh: Works fine (cache is warm)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions