Getting Started
Introduction
Getting Started
What is Spec?
Spec is a JavaScript framework for building user interfaces. It builds on top of standard HTML, CSS, and JavaScript and provides a declarative and component-based programming model that helps you efficiently develop user interfaces, be they simple or complex.
Here is a minimal example:
Terminal
Terminal
Result
The above example demonstrates the two core features of Spec:
Declarative Rendering: Spec extends standard HTML with a template syntax that allows us to declaratively describe HTML output based on JavaScript state.
Reactivity: Spec automatically tracks JavaScript state changes and efficiently updates the DOM when changes happen.
The rest of the documentation assumes basic familiarity with HTML, CSS, and JavaScript. If you are totally new to frontend development, it might not be the best idea to jump right into a framework as your first step - grasp the basics and then come back! You can check your knowledge level with this JavaScript overview. Prior experience with other frameworks helps, but is not required.
Single-File Components
In most build-tool-enabled Spec projects, we author Spec components using an HTML-like file format called Single-File Component. A Spec SFC,
Terminal
SFC is a defining feature of Spec and is the recommended way to author Spec components if your use case warrants a build setup. You can learn more about the how and why of SFC in its dedicated section - but for now, just know that Spec will handle all the build tools setup for you.
Composition API
With Composition API, we define a component's logic using imported API functions. In SFCs, Composition API is typically used with <script setup>. The setup attribute is a hint that makes Spec perform compile-time transforms that allow us to use Composition API with less boilerplate. For example, imports and top-level variables / functions declared in <script setup> are directly usable in the template.
Here is the same component, with the exact same template, but using Composition API and <script setup> instead:
package.json
Finally, create a home page app/page.tsx with some initial content:
Still Got Questions?
For more information on what to do next, we recommend the following sections
What license does Spec use?
What browsers does Spec support?
Is Spec reliable?