Skip to main content

ServerSideRender

A thin wrapper around Gutenberg's @wordpress/server-side-render that adds a consistent dotted-border preview container and disables pointer events so the render is non-interactive in the editor.

import { ServerSideRender } from '@eightshift/frontend-libs-tailwind/scripts';

<ServerSideRender
block='my-theme/latest-posts'
attributes={attributes}
/>;

Highlighted props

PropTypeDescription
blockstringRequired. Fully qualified block name (e.g. my-theme/latest-posts).
attributesobjectBlock attributes passed to the PHP render callback.
classNamestringExtra classes appended to the preview wrapper.

Any other prop is forwarded to the underlying @wordpress/server-side-render — see the WordPress reference for the full list (urlQueryArgs, httpMethod, EmptyResponsePlaceholder, ErrorResponsePlaceholder, LoadingResponsePlaceholder, …).

Custom loading / empty / error states

<ServerSideRender
block='my-theme/latest-posts'
attributes={attributes}
LoadingResponsePlaceholder={() => <Spinner />}
EmptyResponsePlaceholder={() => <p>{__('No posts yet.', 'my-theme')}</p>}
/>