# Bridgetown Lit Renderer Simple pipeline for SSR + hydration of Lit components in your Bridgetown site. ## Installation Run this command to add this plugin to your site's Gemfile, along with Lit 2 and Lit's SSR support: ```shell $ bundle add bridgetown-lit-renderer -g bridgetown_plugins $ yarn add lit @lit-labs/ssr ``` Create a file in `config/lit-ssr.config.js` with the following: ```js const build = require("bridgetown-lit-renderer/build") // You can customize this as you wish, perhaps add new esbuild plugins const esbuildOptions = {} build(esbuildOptions) ``` Add the following to the top of your `frontend/javascript/index.js` file: ```js import "bridgetown-lit-renderer" import "./lit-components" ``` For the purposes of testing your install, add the following to `frontend/javascript/lit-components.js`: ```js import "lit/experimental-hydrate-support.js" import { LitElement, html, css } from "lit" export class HappyDaysElement extends LitElement { static styles = css` :host { display: block; border: 2px dashed gray; margin: 4px; padding: 4px; width: 20vw; } ` static properties = { hello: { type: String } } render() { return html`
Hello ${this.hello}! ${Date.now()}
`; } } customElements.define('happy-days', HappyDaysElement) ``` Finally, create a new `.erb` page somewhere in `src`, and add this somewhere in your template: ```erb <%= lit data: {hello: "there"} do %>