Font Awesome Build Awesome
Search ⌘KCtrl+K
Light Dark System Docs Color Scheme: System \ Default Awesome Shoelace Active Brutalist Glossy Matter Mellow Playful Premium Tailspin Docs Theme: Default Icon Style: Classic Regular
Solid Regular Light Thin Classic Sharp Duotone Sharp Duotone
Docs Most styles require Font Awesome Pro.
Server-Side Rendering: Off Server-Side Rendering Docs
View on GitHub
Start Components Docs Help
Web Awesome Font Awesome Build Awesome
Search this site… /
Light Dark System Docs Color Scheme: System \ Default Awesome Shoelace Active Brutalist Glossy Matter Mellow Playful Premium Tailspin Docs Theme: Default Icon Style: Classic Regular
Solid Regular Light Thin Classic Sharp Duotone Sharp Duotone
Docs Most styles require Font Awesome Pro.
Server-Side Rendering: Off Server-Side Rendering Docs
View on GitHub
Components

Getting Started

  • Installation
  • Usage
  • Forms
  • Localization
  • Frameworks
  • Using with AI
  • Figma Design Kit ProThis requires access to Web Awesome Pro
  • Server Rendering

Resources

  • Accessibility
  • Browser Support
  • Contributing
  • Patterns ProPatterns require access to Web Awesome Pro
  • Migrating from Shoelace
  • Visual Tests
  • Changelog
  • Help & Support

Theming & Utilities

  • Overview
  • Built-in Themes
  • Color Palettes
  • Design Tokens
  • Customizing & Theming
  • CSS Utilities

Actions

  • Button
  • Button Group
  • Copy Button
  • Dropdown
    • Dropdown Item

Forms

  • Checkbox
  • Checkbox Group
  • Color Picker
  • Input
  • Known Date
  • Number Input
  • OTP Input
  • Radio Group
    • Radio
  • Rating
  • Select
    • Option
  • Slider
  • Switch
  • Tag Input
  • Textarea
  • Time Input

Layout

  • Accordion
    • Accordion Item
  • Card
  • Details
  • Dialog
  • Divider
  • Drawer
  • Page
  • Scroller
  • Split Panel
  • Timeline
    • Timeline Item

Navigation

  • Breadcrumb
    • Breadcrumb Item
  • Pagination
  • Stepper
    • Step
  • Tab Group
    • Tab
    • Tab Panel
  • Tree
    • Tree Item

Feedback

  • Badge
  • Callout
  • Progress Bar
  • Progress Ring
  • Skeleton
  • Spinner
  • Tag
  • Toast
    • Toast Item
  • Tooltip

Media

  • Animated Image
  • Avatar
  • Carousel
    • Carousel Item
  • Code Highlighter
  • Comparison
  • Icon
  • Lightbox
    • Lightbox Item
  • Markdown
  • QR Code
  • Zoomable Frame

Data Viz

  • Advanced Usage

Helpers

  • Animation
  • Counter
  • Format Bytes
  • Format Date
  • Format Number
  • Include
  • Intersection Observer
  • Mutation Observer
  • Number Ticker
  • Popover
  • Popup
  • Random Content
  • Relative Time
  • Resize Observer

Express

  • Usage
  • Server-Side Rendering
  • Using a View Engine
  • See It in Action
  • Next Steps
On This Page...
  • Usage
  • Server-Side Rendering
  • Using a View Engine
  • See It in Action
  • Next Steps
Frameworks Express

Express

Using Express with a frontend framework?
Follow the React, Vue, or Svelte page instead, since their setup differs.

Usage

Link to This Section

In a bare-minimum Express app, the following works as expected:

import express from 'express';

const app = express();
const port = 3000;

app.get('/', (req, res) => {
  res.send(`
    <!doctype html>
    <html>
      <head>
        <link rel="stylesheet" href="https://ka-f.webawesome.com/[email protected]/styles/webawesome.css" />
        <script type="module" src="https://ka-f.webawesome.com/[email protected]/webawesome.loader.js"></script>
      </head>
      <body>
        <wa-page>
          <wa-button>Hello World</wa-button>
        </wa-page>
      </body>
    </html>
  `);
});

app.listen(port, () => {
  console.log(`Example app listening on port ${port}`);
});

The key piece is loading Web Awesome's stylesheet and loader in your <head>:

<head>
  <link rel="stylesheet" href="https://ka-f.webawesome.com/[email protected]/styles/webawesome.css" />
  <script type="module" src="https://ka-f.webawesome.com/[email protected]/webawesome.loader.js"></script>
</head>

There are other ways to set up Web Awesome, such as with npm or downloading ZIP files, which are documented on the Installation page.

Web Awesome is ready to use.
Want server-side rendering too?

Add SSR

Server-Side Rendering

Link to This Section

SSR works by rendering your HTML through Lit on the server. First, install Web Awesome locally:

npm install @awesome.me/webawesome

Then add the SSR setup to the top of your server. This registers the components and tells Lit to run each one's connectedCallback while rendering:

// Register all Web Awesome components on the server
import '@awesome.me/webawesome/dist/ssr.js';
// renderString turns an HTML string into a Lit template, runs SSR, and returns a string
import { renderString } from '@awesome.me/webawesome/dist/ssr/render-string.js';
import { LitElementRenderer } from '@lit-labs/ssr';

LitElementRenderer.renderOptions.push(element =>
  element.localName.startsWith('wa-') ? { connectedCallback: true } : undefined,
);

Finally, wrap each HTML response in renderString():

- res.send(`...your HTML...`);
+ res.send(renderString(`...your HTML...`));
// Register all Web Awesome components on the server
import '@awesome.me/webawesome/dist/ssr.js';
// renderString turns an HTML string into a Lit template, runs SSR, and returns a string
import { renderString } from '@awesome.me/webawesome/dist/ssr/render-string.js';
import { LitElementRenderer } from '@lit-labs/ssr';
LitElementRenderer.renderOptions.push(element =>
  element.localName.startsWith('wa-') ? { connectedCallback: true } : undefined,
);

import express from 'express';

const app = express();
const port = 3000;

app.get('/', (req, res) => {
  res.send(
    renderString(`
    <!doctype html>
    <html>
      <head>
        <link rel="stylesheet" href="https://ka-f.webawesome.com/[email protected]/styles/webawesome.css" />
        <script type="module" src="https://ka-f.webawesome.com/[email protected]/webawesome.loader.js"></script>
      </head>
      <body>
        <wa-page>
          <wa-button>Hello World</wa-button>
        </wa-page>
      </body>
    </html>
  `),
  );
});

app.listen(port, () => {
  console.log(`Example app listening on port ${port}`);
});

Using a View Engine

Link to This Section

If you use a view engine such as Pug, Haml, or Nunjucks, add a middleware that runs each rendered view through renderString. It reuses the same SSR setup from above:

This middleware transforms every response through Lit.
If a route can return non-HTML like JSON or CSV, add a content-type check so it skips the transform.

app.set('view engine', 'nunjucks');

// Transform each rendered view through Lit before sending
app.use((req, res, next) => {
  const original = res.render.bind(res);

  res.render = (view, options, callback) => {
    if (typeof options === 'function') {
      callback = options;
      options = {};
    }

    original(view, options, (err, html) => {
      if (err) return typeof callback === 'function' ? callback(err) : next(err);
      const out = renderString(html);
      return typeof callback === 'function' ? callback(null, out) : res.send(out);
    });
  };

  next();
});

See It in Action

Link to This Section
Example Repository

A complete Express SSR project using Web Awesome.

Next Steps

Link to This Section
Components

Start building your interface.

CSS Utilities

Lay out and style without custom CSS.

Theming

Match Web Awesome to your brand.

Express Docs

The official Express documentation.

Using Web Awesome with Express?
Found a bug or have a suggestion? Help make things more awesome!

Share feedback
Go Make Something Awesome
Version 3.15.0 © Fonticons, Inc.
  • Terms
  • Privacy
  • Refunds
  • Core License
  • Pro License

Quick Links

  • Components
  • CSS Utilities
  • Theming
  • Using with AI
  • Changelog
  • Help & Support

Recent Searches

    D'oh! No results for “”

    Suggest on GitHub Ask on Discord
    Navigate Select
    Close Esc