vercel/next.js · error

The server has not been instantiated properly. https://nextj

Error message

The server has not been instantiated properly. https://nextjs.org/docs/messages/invalid-server-options

What it means

Thrown by createServer() when the options argument is null/undefined. Next() requires at least an options object (even an empty one) to instantiate the server; passing nothing leaves it unable to determine dev mode, dir, etc.

Source

Thrown at packages/next/src/server/next.ts:659

      )
    }
  }

  // The package is used as a TypeScript plugin.
  if (
    options &&
    'typescript' in options &&
    'version' in (options as any).typescript
  ) {
    const pluginMod: typeof import('./next-typescript') =
      require('./next-typescript') as typeof import('./next-typescript')
    return pluginMod.createTSPlugin(
      options as any
    ) as unknown as NextWrapperServer
  }

  if (options == null) {
    throw new Error(
      'The server has not been instantiated properly. https://nextjs.org/docs/messages/invalid-server-options'
    )
  }

  if (
    !('isNextDevCommand' in options) &&
    process.env.NODE_ENV &&
    !['production', 'development', 'test'].includes(process.env.NODE_ENV)
  ) {
    log.warn(NON_STANDARD_NODE_ENV)
  }

  if (options.dev && typeof options.dev !== 'boolean') {
    console.warn(
      "Warning: 'dev' is not a boolean which could introduce unexpected behavior. https://nextjs.org/docs/messages/invalid-server-options"
    )
  }

View on GitHub (pinned to 0ae8c72462)

Solutions

  1. Pass an options object, e.g. `next({ dev: process.env.NODE_ENV !== 'production' })`.
  2. Guard the call site: `const app = next(options ?? {})`.
  3. Audit the code path that produces the options variable to ensure it is never null.

Example fix

// before
const app = next(maybeUndefined)
// after
const app = next(maybeUndefined ?? { dev: false })
Defensive patterns

Strategy: validation

Validate before calling

if (options == null) {
  throw new TypeError('next() requires an options object, e.g. next({ dev: false })')
}
const app = next(options)

Type guard

function isValidNextOptions(o: unknown): o is Record<string, unknown> {
  return o != null && typeof o === 'object'
}

Prevention

When it happens

Trigger: Calling `next(null)`, `next(undefined)`, or `require('next')()` with no argument; a variable that was supposed to hold the options object being null due to an earlier assignment bug.

Common situations: Programmatic usage where options were conditionally assigned and fell through to undefined; refactoring that dropped the options argument; TypeScript bypass allowing null.

Related errors


AI-assisted analysis of vercel/next.js@0ae8c72462 (2026-08-06). Data as JSON: /api/errors/b044fadd6311515a. Report an issue: GitHub.