Search packages, repositories and app categories

Package detailsv1.6.0

shelf_hotreload

Wrapper to easily enable hot-reload for shelf applications.

AndroidiOSmacOSWindowsLinux
30-day downloads
291K
Likes
54
Pub points
160

Install package

flutter pub add shelf_hotreload

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

Shelf HotReload is a lightweight wrapper that simplifies hot-reloading for Shelf-based web servers in Flutter applications. It enables developers to automatically restart the server when source files change, improving development efficiency without manual intervention. Designed for use during local development, it integrates seamlessly with Shelf's middleware and routing system. The package supports all major platforms, making it ideal for cross-platform backend services built with Flutter.

Use cases

  • Live code updates during development
  • Rapid iteration on Shelf APIs
  • Cross-platform backend prototyping
  • Development server automation
  • Real-time API testing

Key features

  • Automatic server restart on file changes
  • Simple integration with Shelf routers
  • Supports all Flutter platforms
  • Minimal configuration required
  • Built-in development-only mode

Suitable for

  • Flutter developers building Shelf servers
  • Backend service prototypes
  • Local development workflows
  • Teams prioritizing fast feedback loops
  • Projects using Shelf for HTTP handling

Considerations

  • Not intended for production use
  • Requires manual setup for complex server configurations
  • Limited to development environments
  • May increase startup time slightly
  • Does not support hot-reload for external dependencies

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

shelf_hotreload

Wrapper to easily enable hot-reload for shelf applications.

Usage

import 'dart:io';

import 'package:shelf/shelf.dart' as shelf;
import 'package:shelf/shelf_io.dart' as io;
import 'package:shelf_hotreload/shelf_hotreload.dart';

// Run this app with --enable-vm-service (or use debug run)
void main() async {
  withHotreload(() => createServer());
}

Future<HttpServer> createServer() {
  handler(shelf.Request request) => shelf.Response.ok('hot!');
  return io.serve(handler, 'localhost', 8080);
}

In order to enable hot-reload, you need to run your Dart application with --enable-vm-service (or use debug run in your IDE).

For example:

dart run --enable-vm-service path/to/app.dart
Custom logging

You can also also modify the default logging by providing callbacks:

final myLogger = Logger();

withHotreload(
  () => createServer(),
  onReloaded: () => myLogger.log('Reload!'),
  onHotReloadNotAvailable: () => myLogger.log('No hot-reload :('),
  onHotReloadAvailable: () => myLogger.log('Yay! Hot-reload :)'),
  onHotReloadLog: (log) => myLogger.log('Reload Log: ${log.message}'),
  logLevel: Level.INFO,
);

Categories

Dependencies

Dependency list 2 items

Source repository

Projects using this package

Rankings