Getting Started
/
Quick Start
Quick Start
Define a resource, generate a typed client, and read and write data end to end.
This walks through the full loop: define a model, compile it, generate the client, and use it in React. It takes about five minutes.
Resources are the single source of truth. A field whose type references another resource is a foreign key — the compiler infers the relation, so you never declare it twice.
1
import
{
resource
,
s
}
from
"rastack/define"
;
3
export
const
Airport
=
resource
(
"airports"
,
"airport"
,
{
4
code
:
s
.
string
({
maxLength
:
3
,
unique
:
true
}),
5
name
:
s
.
string
({
maxLength
:
120
}),
6
},
{
search
:
[
"code"
,
"name"
],
admin
:
{
listDisplay
:
[
"code"
,
"name"
]
}
});
8
export
const
Terminal
=
resource
(
"airports"
,
"terminal"
,
{
9
airport
:
s
.
ref
(()
=>
Airport
),
// FK — inferred from the field's type
10
label
:
s
.
string
({
maxLength
:
20
}),
The compiler builds a ts.Program + TypeChecker, walks every resource(...) call, and reads each field's type to emit the canonical manifest and an OpenAPI document.
2
# → schema.rastack.json (the canonical manifest)
3
# → openapi.json (the /api/{app}/v1/{model}/ contract)
3. Generate the typed client
This reads openapi.json and emits one typed hook set per model — useList*, useCreate*, useUpdate*, useDelete* — into your repo.
Wrap your app in a provider (it picks where the engine runs), then import the hooks anywhere:
1
import
{
RAStackProvider
}
from
"rastack/provider"
;
2
import
{
useListTerminals
,
useCreateTerminal
}
from
"@/entities"
;
4
export
function
Terminals
()
{
5
const
{
data
}
=
useListTerminals
();
// typed rows
6
const
create
=
useCreateTerminal
();
8
<
RAStackProvider
mode
=
"local"
>
9
{
data
?.
results
.
map
((
t
)
=>
<
Text
key
={
t
.
id
}>{
t
.
label
}</
Text
>)}
✓ Tip
That is the entire loop. The same generated hooks work unchanged whether the engine runs in the browser, on S3, or on a remote server — see Provider & Runtime Modes. Build with AI
Every page is available as clean Markdown for LLMs and coding agents. Point one at the files below to build on top of React API Stack.
React API Stack · alpha · built to scale to millions