Service invocation

Use DaprClient.invoker.invoke() to call another application through your local Dapr sidecar, and DaprServer.invoker.listen() to receive invocations. The target can also be an existing HTTP application without the JavaScript SDK.

These guides describe @dapr/dapr 3.19.0 or later, including API and transport limitations.

Prerequisites

  • Dapr CLI and an initialized Dapr environment.
  • A supported Node.js LTS release. The package requires Node.js 18 or later.
  • A target application running with a Dapr app ID and application port. No state store or pub/sub component is required.

Install the 3.19.0 release:

npm install @dapr/dapr@3.19.0

For a later release, substitute its version. Examples use ES module imports; run snippets containing await inside an async function or an ES module.

Choose the protocol

The client’s communicationProtocol selects application-to-sidecar communication. The receiving application’s --app-protocol selects sidecar-to-application communication. These are independent: a gRPC client can invoke an HTTP application and an HTTP client can invoke a DaprServer configured for gRPC.

CapabilityHTTP client or servergRPC client or server
client.invoker.invoke()Calls the HTTP invocation APICalls Dapr’s unary InvokeService API
server.invoker.listen()Registers an HTTP routeRegisters an AppCallback.OnInvoke handler
Request verbsGET, POST, PUT, PATCH, DELETESame verbs, carried in the HTTP extension
Custom request headersoptions.headers is forwardedNot forwarded as invocation metadata
Query parameters from the SDK clientAppend an encoded query string to methodNameNo separate query-string option
Default response decodingJSON when parseable; otherwise textJSON required; text or empty responses cause a parse error
Custom application serializerSupportedSupported
Response status and headers through invoke()Not exposedNot exposed
Streaming through invoke()Not supported; responses are bufferedNot supported; unary request/response
client.proxy.create()Not supportedNot supported with the SDK’s ConnectRPC transport

Selecting gRPC does not turn invoke() into a client for arbitrary protobuf services. For native gRPC services, use your generated client with Dapr’s gRPC proxying protocol.

Guides

GuideContents
Calling servicesHTTP and gRPC clients, verbs, headers, paths, query strings, namespaces, and non-Dapr endpoints.
Receiving invocationsA complete server, HTTP and gRPC startup commands, callback data, return values, and existing Express applications.
Configuration and usageClient lifetime, endpoints, authentication, serialization, errors, resiliency, and API limitations.

Implementation references