Ruby on Rails with SSR Svelte

Template for Ruby on Rails app with Svelte installed and configured. Svelte components are server-side-rendered using Hypernova and Rollup.

Getting started

Installation

The following tools are assumed to be installed:

Clone this repository and install all dependencies by running:

# install ruby gems
bundle install
# install npm packages
yarn

Adding components

Per default, all files inside the app/javascript/components that end with .svelte are compiled and available for SSR. To add a new component, simply create a new file containing a Svelte-component:

<!-- inside app/javascript/components/MyComponent.svelte -->
<script>
  export let label;
  let count = 0;
  function handleClick() {
    count += 1;
  }
</script>

<h1>{label}: {count}</h1>
<button on:click={handleClick}>
    Increment {label}
</button>

To use it inside your template, use the provided helper function:

# inside erb-template
<%= render_component 'MyComponent', name: 'Spoons' %>

Top categories

svelte logo

Need a Svelte website built?

Hire a professional Svelte developer today.
Loading Svelte Themes