You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Universal Svelte rendering middleware for Rill.
It is recommended to combine this middleware with @rill/page as seen below to facilitate full page isomorphic rendering with svelte.
Installation
npm install @rill/svelte
Example
importRillfrom'rill'importpagefrom'@rill/page'importrendererfrom'@rill/svelte'importHomeViewfrom'./home.html'// Create a rill app.constapp=Rill()// Setup the document template.app.get(page.html({lang: 'en'}).meta({charset: 'utf8'}).title('My Svelte App').meta({name: 'author',content: 'Dylan Piercey'}).meta({name: 'descripton',content: 'Universal JS is awesome'}).link({rel: 'stylesheet',href: 'index.css'}).script({src: 'index.js',async: true}))// Setup svelte middleware.app.get(renderer())// Render a Svelte template.app.get('/home',({ res, locals })=>{// Set locals passed in as data.locals.title='@rill/svelte'// Set a svelte component as the body to render it.res.body=HomeView})
Custom Render Target.
@rill/svelte adds the ability to change the svelte target element with an option. By default the document.body will be the target element.
// Use a query selector to set the root element.app.use(renderer({target: '#my-element'}))