Version: v5

DevServer

The Re.Pack DevServer is built on top of Fastify and provides a subset of webpack-dev-server configuration options.

Usage

The DevServer is configured through the devServer option in your configuration:

Configuration Options

host

  • Type: string
  • Default: 'localhost'

Hostname or IP address under which to run the development server.

Supported special values:

  • 'local-ip' - Listen on all available network interfaces
  • 'local-ipv4' - Listen on local IPv4 address
  • 'local-ipv6' - Listen on local IPv6 address

port

  • Type: number
  • Default: 8081

Port under which to run the development server.

hot

  • Type: boolean
  • Default: true

Whether to enable Hot Module Replacement (HMR).

server

  • Type: 'http' | 'https' | { type: 'http' } | { type: 'https'; options?: HttpsServerOptions }
  • Default: 'http'

Options for running the server as HTTPS. When set to 'https' or { type: 'https' }, the server will run with HTTPS using default options. For custom HTTPS configuration, provide an options object.

proxy

  • Type: ProxyConfig[]
  • Default: undefined

Configuration for proxying API requests. Each entry in the array defines a proxy rule that forwards matching requests to a target server.

The ProxyConfig extends http-proxy-middleware options with webpack-dev-server compatible aliases:

  • path - Alias for pathFilter
  • context - Alias for pathFilter

setupMiddlewares

  • Type: SetupMiddlewaresFunction
  • Default: undefined

Function to customize middleware setup, allowing you to reorder, modify, or add custom middlewares.

The function receives:

  • middlewares - Array of built-in middlewares
  • devServer - Fastify server instance

Built-in middlewares include:

  • dev-middleware - @react-native/dev-middleware enabling use of React Native Devtools
  • proxy-middleware-* - proxy middlewares created via proxy

Example

Add middleware while respecting middlewares order

Use unshift() to run middleware before all other middlewares or use push() to run middleware after all other middlewares:

Add new route to the DevServer directly

Access the DevServer logger

Access the DevServer instance for routes and logging:

Need React or React Native expertise you can count on?