Getting Started

Coralite is an HTML-first framework designed for building fast, static, and server-rendered web applications using native Web Platform standards. This guide covers project setup, directory structure, authoring your first component and page, and running core commands.

1. Installation #

Coralite ships as a single coralite package: framework runtime and engine, the coralite CLI (development server, build, and testing commands), the defineConfig configuration helper, and the plugin system. You can scaffold a new project using the official create-coralite initializer:

bash
Code copied!
  npm create coralite@latest my-app
  cd my-app
  npm install
  npm run dev

2. Project Structure #

A standard Coralite application uses a simple, predictable directory layout:

text
Code copied!
  my-app/
    components/
      site-header.html
      site-footer.html
    pages/
      index.html
    public/
      favicon.svg
    coralite.config.js
    package.json

3. First Component #

Components in Coralite are authored as HTML files containing a <template> element, an optional <script type="module"> block with top-level named exports (export const attributes, export function server, export function client), and an optional <style> element.

javascript
Code copied!
  <template id="greeting-card">
    <div class="card">
      <h3></h3>
      <p></p>
    </div>
  </template>
  
  &lt;script type="module">
    export const attributes = {
      title: {
        type: String,
        default: 'Hello'
      },
      message: {
        type: String,
        default: 'Welcome to Coralite!'
      }
    }
  &lt;/script&gt;
  
  <style>
    .card {
      padding: 1rem;
      border: 1px solid #ccc;
      border-radius: 4px;
    }
  </style>

You can use this component inside any page or other component using its tag name:

HTML
Code copied!
<greeting-card title="Welcome" message="Enjoy building with Coralite!"></greeting-card>

4. First Page #

Pages are authored inside the pages/ directory. Pages can include a <script type="module"> with flat named exports such as export function server to manage build-time data loading via server().

javascript
Code copied!
  <html lang="en">
  <head>
    <title></title>
  </head>
  <body>
    <h1></h1>
    <p></p>
  </body>
  </html>
  
  &lt;script type="module">
    export function server () {
      return {
        pageTitle: 'Home — My Coralite Site',
        headline: 'Build Fast Static & SSR Websites',
        description: 'Coralite combines native Web Components with build-time SSR.'
      }
    }
  &lt;/script&gt;

5. Scripts #

The create-coralite scaffolder configures five core lifecycle scripts in package.json:

6. Where Next #

Continue exploring the Coralite documentation:


Next: Explore the Authoring Pattern to master Coralite's unified structure.

Start Building with Coralite!

Use the scaffolding script to get jump started into your next project with Coralite

Copied commandline!