> For the complete documentation index, see [llms.txt](https://reduxbundler.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://reduxbundler.com/api-reference/middlewares.md).

# Included Middleware

Redux-bundler includes a few middlewares by default:

## Slightly modified `redux-thunk`

Works like `redux-thunk` except that everything is passed as a single argument and since all our selectors and action creators are attached to the store instance we also pass the store itself, plus anything bundles may have added by using `getExtraArgs`. So it ends up passing something like this as an argument `{dispatch, store, getState, ...extraArgs}` to your thunk function.

This lets you write action creators that don't care about argument position:

```javascript
export const doCoolStuff =
  () =>
  ({ dispatch, myApiWrapper }) => {
    dispatch({ type: 'USER_FETCH_STARTED' })
    return myApiWrapper('/some-resource')
      .then(payload => {
        dispatch({ type: 'USER_FETCH_FINISHED', payload })
      })
      .catch(() => {
        dispatch({ type: 'USER_FETCH_FAILED' })
      })
  }
```

## Debug Middleware

If you're using the `debugBundle` it will also add some logging middleware that logs actions and state with each action and shows you the next reactor that will be dispatched.

## Named Action Middleware

The bundle created by `createReactorBundle` will also inject middleware that allows you to dispatch an object that names the action creator to be used and optionally the arguments to pass to it.

For example dispatching `{actionCreator: 'doLogOut', args: [true]}` would be the same as calling `store.doLogOut(true)`.

This is most useful when writing reactor functions in a bundle where you may not have a direct reference to the action creator function you want to call.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://reduxbundler.com/api-reference/middlewares.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
