core README

The project's README from github.com/stenciljs/core. As one markdown file: README.md.

stencil-logo

Stencil

A compiler for generating Web Components using technologies like TypeScript and JSX, built by the Ionic team.

StencilJS is released under the MIT license. StencilJS is released under the MIT license. PRs welcome! Follow @stenciljs Official Ionic Discord

Quick Start · Documentation · Contribute · Blog
Community: Discord · Forums · Twitter

Getting Started

Start a new project by following our quick Getting Started guide. We would love to hear from you! If you have any feedback or run into issues using Stencil, please file an issue on this repository.

Examples

A Stencil component looks a lot like a class-based React component, with the addition of TypeScript decorators:

import { Component, Prop, h } from '@stencil/core';

@Component({
  tag: 'my-component',            // the name of the component's custom HTML tag
  styleUrl: 'my-component.css',   // css styles to apply to the component
  shadow: true,                   // this component uses the ShadowDOM
})
export class MyComponent {
  // The component accepts two arguments:
  @Prop() first: string;
  @Prop() last: string;

   //The following HTML is rendered when our component is used
  render() {
    return (
      <div>
        Hello, my name is {this.first} {this.last}
      </div>
    );
  }
}

The component above can be used like any other HTML element:

<my-component first="Stencil" last="JS"></my-component>

Since Stencil generates web components, they work in any major framework or with no framework at all. In many cases, Stencil can be used as a drop in replacement for traditional frontend framework, though using it as such is certainly not required.

Contributing

Thanks for your interest in contributing! Please take a moment to read up on our guidelines for contributing. We've created comprehensive technical documentation for contributors that explains Stencil's internal architecture, including the compiler, runtime, build system, and other core components in the /docs directory. Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

core (stenciljs/core)

Searching Database…

13.1K ·GitHub
What is this?Stencil is a compiler that generates standards-based Web Components using TypeScript and JSX, letting you build a single component library that works natively in React, Angular, Vue, and plain web apps.
Is Stencil a framework or a compiler?It is a compiler/toolchain rather than a runtime framework — it compiles your components into standard Web Components with no framework lock-in, so the output can be dropped into any app or none at all.
How do I start a new Stencil project?You follow the official Getting Started guide, which scaffolds a new Stencil component project for you.
Do I need a specific Node or npm version?Yes, Stencil requires Node.js 16 or later and npm 7.10 or later to build and develop.
Do I need to know TypeScript decorators and JSX to write components?Yes — a Stencil component is written as a TypeScript class with Stencil decorators and uses JSX for templating, similar in style to a class-based React component.
Does Stencil replace frameworks like React or Angular?Not necessarily — Stencil can serve as a drop-in replacement for a frontend framework, but using it that way isn't required since the generated components also work alongside existing frameworks.
Can Stencil-built components be used without any JavaScript framework?Yes, since they compile to native Web Components, Stencil components run in plain HTML/JS pages with no framework at all.
Does Stencil support server-side rendering or static site generation?The project's topics include SSR, SSG, and static-site-generator, indicating it can pre-render components for those use cases.
Why would I pick Stencil over writing separate React or Vue components?Stencil lets you write one component codebase and distribute it natively to React, Angular, Vue, and vanilla web apps, avoiding duplicate implementations per framework.
Creator
stenciljs
Size
88.3 MB
Stars
13.1K
Age
9y
Commits · 90 Days