Code Monkey home page Code Monkey logo

lit-ssr-express-template's Introduction

Express + Lit + SSR Web App Template

This is a template for creating an express app that uses the Lit web framework and server-side rendering (SSR) to render web components.

Structure

  • Templates exist in the src/templates folder. They are functions that take two arguments: a Page, and Data. The templates return an HTMLTemplateResult.
  • Pages are inside the src/pages folder. They must export a template that will be used to render the page. They must also export a page which is a function that takes one argument: data. Pages can export any arbitrary variables and they will be fed into the data argument. Pages must export a route that determines the path the page is available at, for example: export const route = '/api' will make the page available at /api in the browser. Pages must also export a get function or a post function that will be used when rendering the page. Pages must be a ..ts file, for example: index.html.ts.
  • All Lit elements should live within the src/components directory. These are compiled twice. Once for the server, and once for the client.

Usage

To use this template, you will need to have Node.js and npm installed.

  1. Clone this repository: git clone https://github.com/WillsonSmith/Lit-SSR-Express-Template
  2. Install dependencies: npm install
  3. Run the development server: npm start
  4. Open your browser to http://localhost:3000 to see the app running

Limitations

If you want to add variables within the or onto the tags you must append -so to the tag. The render function will strip these out when rendering the page. For example: Hello World. This template is set up to use Prisma with SQLite for the database.

lit-ssr-express-template's People

Contributors

willsonsmith avatar

Stargazers

jeremyyang avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.