Skip to content
Twilight React Playground
ثيم رائدaren

Learn

A guided track from native JavaScript to a working theme feature.

A guided path for developers who know native JavaScript. Read the pages in order: each one adds a single idea, shows it running in the engine, and ends with something to try.

1. What a theme is, and what the engine does for you

A theme is a small app you own; the engine supplies its pages, data loading and the connection to Salla.

Beginner8 min
2. From document.createElement to JSX

The same product card built with DOM calls and with JSX, side by side, and the few rules JSX adds.

Beginner8 min
3. Components and props

A component is a function that returns JSX, props are its arguments, and the engine's ProductCard works the same way.

Beginner8 min
4. What a hook is

Functions whose name starts with use: what they give a component, and the two rules for calling them.

Beginner6 min
5. State and re-rendering

Why React runs your component again, how to watch it happen, and how engine hooks follow data that changes outside React.

Beginner10 min
6. Server rendering and hydration

Every page runs twice, on the server then in the browser: what exists where, and how to avoid "window is not defined".

Beginner10 min
7. The provider: data every component can reach

Context shares values without passing props; TwilightProvider shares the store, theme and language, and useTwilight reads them.

Beginner8 min
8. Reading store data

Build a small store header one hook at a time with useStore, useTheme, useAsset and useTranslation.

Beginner10 min
9. Money, dates and numbers

Format prices, dates and digits the way the store and the page language expect, with useMoney, useDate and useNumber.

Beginner9 min
10. Translations and right-to-left

Show text in the page language with t(), and build layouts that flip correctly between Arabic and English.

Beginner10 min
11. URLs, routes and pages

How an address becomes a page, how a component tells which page it is on, and how to add routes of your own.

Beginner15 min
12. Loading data with loaders and queries

Fetch store data before a page renders with a loader, or from a component with useQuery, sharing one cache.

Beginner12 min
13. Changing data in the browser: the Salla SDK

Add to cart and other actions go through window.Salla in the browser; listen to its events and clean up after yourself.

Beginner12 min
14. Adding content without editing a page: hook slots

Engine pages leave named slots; register a function for a name and what it returns appears on every page with that slot.

Beginner9 min
15. Swapping a component: the registry

Replace the engine's product card everywhere by registering your own component under product:card.

Beginner8 min
16. Page titles and SEO

Set the title, description and share tags in a page's head, with a route's head function and withHead.

Beginner9 min
17. Putting it together: a free-shipping progress bar

Combine a theme setting, money formatting, translations, cart events and a hook slot into one feature.

Beginner15 min