The Fire generator creates a new Fire-object, which is the class containing all the app logic. The class is based on the R6 OO-system and is thus reference-based with methods and data attached to each object, in contrast to the more well known S3 and S4 systems. A fiery server is event driven, which means that it is build up and manipulated by adding event handlers and triggering events. To learn more about the fiery event model, read the event vignette. fiery servers can be modified directly or by attaching plugins. As with events, plugins has its own vignette.


A new 'Fire'-object is initialized using the new() method on the generator:


app <- Fire$new(host = '', port = 8080L)


hostA string overriding the default host (see the Fields section below)
portAn integer overriding the default port (see the Fields section below)


As Fire objects are using reference semantics new copies of an app cannot be made simply be assigning it to a new variable. If a true copy of a Fire object is desired, use the clone() method.



A string giving a valid IPv4 address owned by the server, or '' to listen on all addresses. The default is ''


An integer giving the port number the server should listen on (defaults to 8080L)


The interval in seconds between run cycles when running a blocking server (defaults to 0.001)


The interval in seconds between run cycles when running a non-bocking server (defaults to 1)


A valid folder where trigger files can be put when running a blocking server (defaults to NULL)


A named list of the already attached plugins. Static - can only be modified using the attach() method.


The location of the app. Setting this will remove the root value from requests (or decline them with 400 if the request does not match the root). E.g. the path of a request will be changed from /demo/test to /test if root == '/demo'


A glue string defining how requests will be logged. For standard formats see common_log_format and combined_log_format. Defaults to the Common Log Format


ignite(block = TRUE, showcase = FALSE, ...)

Begins the server, either blocking the console if block = TRUE or not. If showcase = TRUE a browser window is opened directing at the server address. ... will be redirected to the start handler(s)

start(block = TRUE, showcase = FALSE, ...)

A less dramatic synonym of for ignite()

reignite(block = TRUE, showcase = FALSE, ...)

As ignite but additionally triggers the resume event after the start event

resume(block = TRUE, showcase = FALSE, ...)

Another less dramatic synonym, this time for reignite()


Stops a running server


Boring synonym for extinguish()


Check if the server is currently running

on(event, handler, pos = NULL)

Add a handler function to to an event at the given position (pos) in the handler stack. Returns a string uniquely identifying the handler. See the event vignette for more information.


Remove the handler tied to the given id

trigger(event, ...)

Triggers an event passing the additional arguments to the potential handlers

send(message, id)

Sends a websocket message to the client with the given id, or to all connected clients if id is missing

log(event, message, request, ...)

Send a message to the logger. The event defines the type of message you are passing on, while request is the related Request object if applicable.


Closes the websocket connection started from the client with the given id, firing the websocket-closed event

attach(plugin, ..., force = FALSE)

Attaches a plugin to the server. See the plugin vignette for more information. Plugins can only get attached once unless force = TRUE


Check whether a plugin with the given name has been attached

header(name, value)

Add a global header to the server that will be set on all responses. Remove by setting value = NULL

set_data(name, value)

Adds data to the servers internal data store


Extracts data from the internal data store


Removes the data with the given name from the internal data store

time(expr, then, after, loop = FALSE)

Add a timed evaluation (expr) that will be evaluated after the given number of seconds (after), potentially repeating if loop = TRUE. After the expression has evaluated the then function will get called with the result of the expression and the server object as arguments.


Removes the timed evaluation identified by the id (returned when adding the evaluation)

delay(expr, then)

Similar to time(), except the expr is evaluated immediately at the end of the loop cycle (see here for detailed explanation of delayed evaluation in fiery).


Removes the delayed evaluation identified by the id

async(expr, then)

As delay() and time() except the expression is evaluated asynchronously. The progress of evaluation is checked at the end of each loop cycle


Removes the async evaluation identified by the id. The evaluation is not necessarily stopped but the then function will not get called.


Sets the function that converts an HTTP request into a specific client id


Sets the function that takes care of logging


Sets the function that converts an HTTP request into a specific client id


Create a copy of the full Fire object and return that


# Create a New App app <- Fire$new(port = 4689) # Setup the data every time it starts app$on('start', function(server, ...) { server$set_data('visits', 0) server$set_data('cycles', 0) }) # Count the number of cycles app$on('cycle-start', function(server, ...) { server$set_data('cycles', server$get_data('cycles') + 1) }) # Count the number of requests app$on('before-request', function(server, ...) { server$set_data('visits', server$get_data('visits') + 1) }) # Handle requests app$on('request', function(server, ...) { list( status = 200L, headers = list('Content-Type' = 'text/html'), body = paste('This is indeed a test. You are number', server$get_data('visits')) ) }) # Show number of requests in the console app$on('after-request', function(server, ...) { message(server$get_data('visits')) flush.console() }) # Terminate the server after 300 cycles app$on('cycle-end', function(server, ...) { if (server$get_data('cycles') > 300) { message('Ending...') flush.console() server$extinguish() } }) # Be polite app$on('end', function(server) { message('Goodbye') flush.console() }) if (FALSE) { app$ignite(showcase = TRUE) }