INNER CODE UNIT · TypeScript

getSharedInstance

i18next/next-i18next · src/appRouter/server.ts:108

async function getSharedInstance(state: ServerState): Promise<I18NextClient> {
  const { config } = state
  if (state.instance?.isInitialized) return state.instance

  // Deduplicate concurrent init calls (multiple requests arriving while first init is in flight)
  if (state.instancePromise) return state.instancePromise

  state.instancePromise = (async () => {
    const i18nInstance = createInstance()

    // Add a backend when needed:
    // - No resources provided → backend loads everything
    // - Resources provided with partialBundledLanguages → backend loads the rest
    // - Custom backend in config.use → user handles it, skip default backend
    const partialBundled = config.i18nextOptions?.partialBundledLanguages
    if ((!config.resources || partialBundled) && !hasCustomBackend(config.use)) {
      i18nInstance.use(createResourceBackend(config))
    }

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…