Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/antony/hapi-svelte-views

Svelte view plugin for HapiJS, which supports SSR and CSR
https://github.com/antony/hapi-svelte-views

csr hapi hapijs ssr static static-site static-site-generator svelte svelte3 sveltejs views vision

Last synced: 11 days ago
JSON representation

Svelte view plugin for HapiJS, which supports SSR and CSR

Awesome Lists containing this project

README

        

## Hapi Svelte Views

Status: Working, but experimental

![publish](https://github.com/antony/hapi-svelte-views/workflows/publish/badge.svg)
[![NPM version](https://img.shields.io/npm/v/hapi-svelte-views.svg)](https://www.npmjs.com/package/hapi-svelte-views)

### Installation and Usage

```bash
npm install --save-dev hapi-svelte-views svelte @hapi/vision
```

```js
// server.js
const Vision = require('@hapi/vision')
const Svelte = require('hapi-svelte-views')

// ... your server set-up here ...

// Register Vision and Svelte plugins
await server.register(Vision);
await server.register(Svelte);

// Configure Vision / Svelte plugins
server.views({
engines: {
svelte: Svelte
},
relativeTo: __dirname,
path: 'views' // Put your .svelte components into 'views'
})

// Some Route
server.route({
method: 'GET',
path: '/',
handler: (request, h) => {
// Render Home view and pass it some props
const props = { name: 'World' }
const layout = 'BasicLayout'
return h.view('Home', { layout, props })
}
})
```

```js
// views/Home.svelte

Hello {name}!


```

```js
// views/BasicLayout.svelte


  • Brand






```