> Markdown version of [Server Push](https://vaadin.com/docs/latest/flow/advanced/server-push). Section index: [llms.txt](https://vaadin.com/docs/latest/flow/llms.txt)

# <a id="push.configuration"></a>Server Push Configuration

Server push is based on a client-server connection established by the client. The server can then use the connection to send updates to the client. Vaadin uses the [Atmosphere framework](https://github.com/Atmosphere/atmosphere) internally for server push communication.

For practical usage guides and patterns, see [Server Push](https://vaadin.com/docs/latest/building-apps/server-push.md) in the Building Apps section.

## <a id="push.configuration.annotation"></a>The @Push Annotation

Enable server push by adding the `@Push` annotation to the class implementing `AppShellConfigurator`:

```java
@Push
public class Application implements AppShellConfigurator {
  ...
}
```

The annotation supports the following parameters:

| Parameter   | Default                   | Description                                                                      |
| ----------- | ------------------------- | -------------------------------------------------------------------------------- |
| `value`     | `PushMode.AUTOMATIC`      | The push mode. See [Push Modes](#push.configuration.pushmode).                   |
| `transport` | `Transport.WEBSOCKET_XHR` | The transport mechanism. See [Transport Options](#push.configuration.transport). |

## <a id="push.configuration.pushmode"></a>Push Modes

Server push operates in one of three modes:

| Mode                 | Description                                                                                                                 |
| -------------------- | --------------------------------------------------------------------------------------------------------------------------- |
| `PushMode.AUTOMATIC` | Changes are pushed to the browser automatically after `UI.access()` finishes. This is the default mode.                     |
| `PushMode.MANUAL`    | Changes are pushed only when you explicitly call `UI.push()`. Use this for fine-grained control over when updates are sent. |
| `PushMode.DISABLED`  | Server push is disabled. Use this to explicitly disable push when needed.                                                   |

Example with manual mode:

```java
@Push(PushMode.MANUAL)
public class Application implements AppShellConfigurator {
  ...
}
```

## <a id="push.configuration.transport"></a>Transport Options

<!-- vale Vaadin.Abbr = NO -->

Server push supports the following transport mechanisms:

| Transport                      | Description                                                                                                                                                                                  |
| ------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `Transport.WEBSOCKET_XHR`      | Combined WebSockets and XHR. WebSocket is used for server-to-client communication, and XHR for client-to-server communication. This is the default and recommended transport.                |
| `Transport.WEBSOCKET`          | Pure WebSocket connection.                                                                                                                                                                   |
| `Transport.LONG_POLLING`       | HTTP long polling. Use this if WebSocket connections are blocked by proxies or firewalls.                                                                                                    |
| `Transport.SERVER_SENT_EVENTS` | Server-sent events for server-to-client communication, and XHR for client-to-server communication. Experimental; see [Server-Sent Events (Experimental)](#push.configuration.transport.sse). |

<!-- vale Vaadin.Abbr = YES -->

Example with long polling:

```java
@Push(transport = Transport.LONG_POLLING)
public class Application implements AppShellConfigurator {
  ...
}
```

### <a id="push.configuration.transport.sse"></a>Server-Sent Events (Experimental) (new in V25.3)

`Transport.SERVER_SENT_EVENTS` streams server-to-client messages using the browser’s `EventSource` API, while client-to-server messages are sent as regular XHR requests. It can help when running behind proxies or firewalls that allow plain HTTP streaming but block WebSocket connections.

This transport is experimental and requires enabling the `ssePushTransport` feature flag; see [Feature Flags](https://vaadin.com/docs/latest/flow/configuration/feature-flags.md). Selecting it while the feature flag is disabled throws a `DisabledFeatureException`.

```java
@Push(transport = Transport.SERVER_SENT_EVENTS)
public class Application implements AppShellConfigurator {
  ...
}
```

## <a id="push.configuration.servlet"></a>Servlet Configuration

If you’re manually configuring your servlet, set the `async-supported` parameter to enable push support.

You can also configure push mode for the entire application in the servlet configuration with the `pushMode` parameter in the `web.xml` deployment descriptor, or a corresponding `@WebServlet` annotation.

On the server side, the push endpoint is mapped to the `VAADIN/push` path. This mapping is added either under context root, context path, or the first URL mapping (sorted by natural order and ignoring `/VAADIN/*` and `/vaadinServlet/*`) of the Vaadin servlet, depending on application deployment configuration. For multiple servlet mappings, configure the `pushServletMapping` parameter to match the desired mapping.

## <a id="push.access"></a>UI.access() Method

Making changes to a UI from another thread requires locking the user session to prevent conflicts with regular event-driven updates. Use the `UI.access()` method to safely update the UI from background threads:

```java
ui.access(() -> statusLabel.setText(statusText));
```

With manual push mode, call `UI.push()` explicitly:

```java
ui.access(() -> {
    statusLabel.setText(statusText);
    ui.push();
});
```

For detailed patterns and best practices for using `UI.access()`, including how to avoid memory leaks and flooding, see [Pushing UI Updates](https://vaadin.com/docs/latest/building-apps/server-push/updates.md).

`77E22B23-4E6A-4D32-AFCC-2423F633F81D`
