Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

Redux Toolkit · Type Alias

SerializedError

SerializedError is Redux Toolkit’s plain, serializable representation of an error. It optionally carries the error name, message, stack, and code.

How it works

SerializedError is the plain error shape Redux Toolkit uses after serializing an error. Its four optional string properties preserve common diagnostic details without requiring an Error instance.

Syntax

export interface SerializedError {
  name?: string
  message?: string
  stack?: string
  code?: string
}

Key points

  • miniSerializeError converts an object error into a plain serialized object.
  • Non-object inputs are represented differently instead of receiving the four interface fields.
  • The type exposes four optional string fields: name, message, stack, and code.
  • Unhandled thunk failures place the serialized error in the rejected action's error field.
  • RTK Query fetch results can expose SerializedError alongside FetchBaseQueryError or no error.

Common mistakes

  • When another API permits multiple error shapes, narrow the value before reading SerializedError properties.
  • For RTK Query results, first distinguish SerializedError from other possible error types.

Example: Reading a serialized error

import type { SerializedError } from '@reduxjs/toolkit'

export function formatError(error: SerializedError): string {
  return error.message ?? error.name ?? 'Unknown error'
}

Accepts the documented optional fields and safely chooses a display string.

When to use it

Read standard details from rejected thunk actions

Thunk failure handling

Handle serialized errors returned by query hooks

RTK Query error handling

Show a safe fallback when message is absent

Error display

Interview questions

QWhat is SerializedError?

SerializedError is an interface with optional string properties named name, message, stack, and code. It describes a serializable error value rather than an Error instance.

Follow-up: Why are its properties optional? Serialization may receive values that do not provide every conventional Error field, so consumers must handle missing fields.

QWhen does createAsyncThunk produce a SerializedError?

createAsyncThunk uses an automatically serialized error in the rejected action when the promise fails without rejectWithValue. The resulting value is available as action.error.

Follow-up: How can a thunk provide a custom structured failure? Catch the failure and return thunkAPI.rejectWithValue(value), which places that value in action.payload.

QWhat fields and types does SerializedError contain?

The documented declaration is export interface SerializedError { name?: string; message?: string; stack?: string; code?: string }. Every field is optional and has type string.

Follow-up: What should TypeScript code do before accessing a union containing this type? Narrow the union to SerializedError or another known error shape first.

  • miniSerializeError
  • createAsyncThunk
  • FetchBaseQueryError
  • rejectWithValue

Source: Other Exports. Checked 2026-10-15.