Getting Started
/
Quick Start
Quick Start
Define a resource, generate a typed client, and read and write data end to end.
View as Markdown
llms.txt
This walks through the full loop: define a model, compile it, generate the client, and use it in React. It takes about five minutes.
1. Define a resource
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.
resources/airports.ts
ts · copy
1
import
{
resource
,
s
}
from
"rastack/define"
;
2
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"
]
}
});
7
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
}),
11
});
2. Compile
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.
terminal
bash · copy
1
npx
rastack
compile
2
# → schema.rastack.json (the canonical manifest)
3
# → openapi.json (the /api/{app}/v1/{model}/ contract)
3. Generate the typed client
terminal
bash · copy
1
npx
rastack
generate
This reads openapi.json and emits one typed hook set per model — useList*, useCreate*, useUpdate*, useDelete* — into your repo.
4. Use it in React
Wrap your app in a provider (it picks where the engine runs), then import the hooks anywhere:
app/terminals.tsx
tsx · copy
1
import
{
RAStackProvider
}
from
"rastack/provider"
;
2
import
{
useListTerminals
,
useCreateTerminal
}
from
"@/entities"
;
3
4
export
function
Terminals
()
{
5
const
{
data
}
=
useListTerminals
();
// typed rows
6
const
create
=
useCreateTerminal
();
7
return
(
8
<
RAStackProvider
mode
=
"local"
>
9
{
data
?.
results
.
map
((
t
)
=>
<
Text
key
={
t
.
id
}>{
t
.
label
}</
Text
>)}
10
</
RAStackProvider
>
11
);
12
}
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