All Projects → PierBover → svelte-ssr-example

PierBover / svelte-ssr-example

Licence: other
Svelte SSR example

Programming Languages

javascript
184084 projects - #8 most used programming language
HTML
75241 projects
CSS
56736 projects

Projects that are alternatives of or similar to svelte-ssr-example

fastify-openapi-glue
A plugin for Fastify to autogenerate a configuration based on a OpenApi(v2/v3) specification.
Stars: ✭ 94 (+118.6%)
Mutual labels:  fastify
Notadd
A microservice development architecture based on nest.js. —— 基于 Nest.js 的微服务开发架构。
Stars: ✭ 2,556 (+5844.19%)
Mutual labels:  fastify
fastify-autoroutes
fastest way to map directories to URLs in fastify
Stars: ✭ 70 (+62.79%)
Mutual labels:  fastify
docker-fastify-restful-api
Node.js RESTful API boilerplate using Traefik, Docker, Docker Compose, Fastify, JWT and Mongodb
Stars: ✭ 40 (-6.98%)
Mutual labels:  fastify
Permit
An unopinionated authentication library for building Node.js APIs.
Stars: ✭ 1,654 (+3746.51%)
Mutual labels:  fastify
fastify-jwt-authz
Verify authenticated user scope
Stars: ✭ 14 (-67.44%)
Mutual labels:  fastify
fastify-response-validation
A simple plugin that enables response validation for Fastify.
Stars: ✭ 20 (-53.49%)
Mutual labels:  fastify
nest-rest-typeorm-boilerplate
🍱 backend with nest (typescript), typeorm, and authentication
Stars: ✭ 142 (+230.23%)
Mutual labels:  fastify
Electrode
Web applications with node.js and React
Stars: ✭ 2,033 (+4627.91%)
Mutual labels:  fastify
fullstack-graphql-app
An opinionated fullstack GraphQL monorepo boilerplate using pnpm, Turborepo, Prisma, GraphQL Yoga 2, Fastify, Nextjs, urql, and React
Stars: ✭ 90 (+109.3%)
Mutual labels:  fastify
audnexus
An audiobook data aggregation API, combining multiple sources of data into one, consistent source.
Stars: ✭ 18 (-58.14%)
Mutual labels:  fastify
Http Proxy Middleware
⚡ The one-liner node.js http-proxy middleware for connect, express and browser-sync
Stars: ✭ 8,730 (+20202.33%)
Mutual labels:  fastify
nodejs-integration-tests-best-practices
✅ Beyond the basics of Node.js testing. Including a super-comprehensive best practices list and an example app (April 2022)
Stars: ✭ 2,842 (+6509.3%)
Mutual labels:  fastify
hc-pdf-server
Convert HTML to PDF Server by headless chrome with TypeScript. The new version of hcep-pdf-server.
Stars: ✭ 24 (-44.19%)
Mutual labels:  fastify
fastify-cron
Run cron jobs alongside your Fastify server 👷
Stars: ✭ 32 (-25.58%)
Mutual labels:  fastify
framework
The target of this framework is to help in all the needs of a full featured API REST, from top to bottom, and at the same time having the best possible performance and security.
Stars: ✭ 88 (+104.65%)
Mutual labels:  fastify
node-fastify-mongo-api
Node.js Restful API starter template
Stars: ✭ 77 (+79.07%)
Mutual labels:  fastify
fastify-metrics
📊 Fastify plugin that integrates metrics collection and dispatch to statsd
Stars: ✭ 62 (+44.19%)
Mutual labels:  fastify
fastify-accepts
Add accepts parser to fastify
Stars: ✭ 51 (+18.6%)
Mutual labels:  fastify
fastify-file-upload
Fastify plugin for uploading files
Stars: ✭ 68 (+58.14%)
Mutual labels:  fastify

Svelte SSR example

Features:

  • Svelte 3
  • SSR with hydration client-side
  • Isomorphic (use the same components server-side and client-side)
  • Hashed JS and CSS filenames
  • Global SCSS
  • Component SCSS (use <style lang="scss">)
  • Using Fastify but any Node server can be used

See this running on Heroku: https://svelte-ssr-test.herokuapp.com/

(it's a free dyno, it may be asleep)

Intro

I was looking for an SSR example for Svelte but the only one I could find seemed unnecessarily complicated. So I decided to create this example which I think is more educational.

I'm a Rollup and Svelte noob. Don't hesitate to open an issue if I did something wrong.

How to dev?

Run npm run rollup-watch and then npm run server-watch on another shell. Not very elegant but still better than manually doing npm run start whenever you want to refresh a change, is it not?

If you add a new file to components/pages you will need to restart Rollup's watch. I haven't found a way of making Rollup react to new files. If you know how please answer this StackOverflow question!

Instead of having two terminal tabs you could create a new NPM command on package.json like this:

"dev": "npm run rollup-watch & npm run scss-watch & npm run server-watch"

This would run those commands at the same time in parallel (note the single &) but all outputs will be mixed. Also, this doesn't work on Windows.

Why not Sapper?

Sapper apps respond the first request by doing SSR but after that it becomes a single-page-application (SPA) with code splitting. This is fancy but introduces a number of issues:

  1. You will need to feed both server and client with data so you have no choice than to create an API. With a purely SSR'd app you may not need to do that since you can query the DB and simply return HTML.

  2. HTTP requests have to work in both Node and the browser. This shouldn't be a problem for public endpoints but it will be challenging if your API uses cookies or JWT for authentication.

  3. After the initial request Sapper apps become a SPA. This introduces a number of issues typical of SPAs. Eg: forms are not filled when going back.

(If someone from the Sapper team reads this: It would be great if Sapper had a purely SSR mode wink wink)

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].