BackendTask.Custom

In a vanilla Elm application, Ports let you either send or receive JSON data between your Elm application and the JavaScript context in the user's browser at runtime.

With BackendTask.Custom, you send and receive JSON to JavaScript running in NodeJS. As with any BackendTask, Custom BackendTask's are either run at build-time (for pre-rendered routes) or at request-time (for server-rendered routes). See BackendTask for more about the lifecycle of BackendTask's. page , page

This means that you can call shell scripts, run NPM packages that are installed, or anything else you could do with NodeJS to perform custom side-effects, get some data, or both. A BackendTask.Custom will call an async JavaScript function with the given name from the definition in a file called custom-backend-task.ts in your project's root directory. The function receives the input JSON value, and the Decoder is used to decode the return value of the async function.