@bractjs/bractjs 0.1.0 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# BractJS
|
|
2
2
|
|
|
3
|
-
> Production-grade SSR framework for Bun + React
|
|
3
|
+
> Production-grade SSR framework for Bun + React.
|
|
4
4
|
> File-based routing · Parallel loaders · Streaming SSR · Built-in HMR · Server Actions
|
|
5
5
|
|
|
6
6
|
---
|
|
@@ -41,8 +41,8 @@ Place files inside `app/routes/`. BractJS scans them at startup.
|
|
|
41
41
|
Every file in `app/routes/` can export any combination of these:
|
|
42
42
|
|
|
43
43
|
```tsx
|
|
44
|
-
import type { LoaderArgs, ActionArgs, MetaArgs } from "bractjs";
|
|
45
|
-
import { redirect } from "bractjs";
|
|
44
|
+
import type { LoaderArgs, ActionArgs, MetaArgs } from "@bractjs/bractjs";
|
|
45
|
+
import { redirect } from "@bractjs/bractjs";
|
|
46
46
|
|
|
47
47
|
// Runs on every GET — return value becomes useLoaderData()
|
|
48
48
|
export async function loader({ request, params, context }: LoaderArgs) {
|
|
@@ -86,7 +86,7 @@ export default function BlogPost() {
|
|
|
86
86
|
Required. Provides the `<html>` document shell.
|
|
87
87
|
|
|
88
88
|
```tsx
|
|
89
|
-
import { Scripts, LiveReload, Outlet } from "bractjs";
|
|
89
|
+
import { Scripts, LiveReload, Outlet } from "@bractjs/bractjs";
|
|
90
90
|
|
|
91
91
|
export function meta() {
|
|
92
92
|
return [{ title: "My App" }, { name: "viewport", content: "width=device-width, initial-scale=1" }];
|
|
@@ -113,8 +113,8 @@ export default function Root() {
|
|
|
113
113
|
`defer()` streams slow data without blocking the initial HTML response.
|
|
114
114
|
|
|
115
115
|
```tsx
|
|
116
|
-
import { defer } from "bractjs";
|
|
117
|
-
import { Await } from "bractjs";
|
|
116
|
+
import { defer } from "@bractjs/bractjs";
|
|
117
|
+
import { Await } from "@bractjs/bractjs";
|
|
118
118
|
import { Suspense } from "react";
|
|
119
119
|
|
|
120
120
|
export async function loader({ params }: LoaderArgs) {
|
|
@@ -148,7 +148,7 @@ export default function BlogPost() {
|
|
|
148
148
|
Soft-navigates without a full reload. `prefetch="hover"` preloads the route chunk + loader data on mouse-enter.
|
|
149
149
|
|
|
150
150
|
```tsx
|
|
151
|
-
import { Link } from "bractjs";
|
|
151
|
+
import { Link } from "@bractjs/bractjs";
|
|
152
152
|
|
|
153
153
|
<Link to="/blog/42">Read Post</Link>
|
|
154
154
|
<Link to="/about" prefetch="hover">About</Link>
|
|
@@ -159,7 +159,7 @@ import { Link } from "bractjs";
|
|
|
159
159
|
Fetch-based submission. Re-runs the current route's loader after the action completes.
|
|
160
160
|
|
|
161
161
|
```tsx
|
|
162
|
-
import { Form } from "bractjs";
|
|
162
|
+
import { Form } from "@bractjs/bractjs";
|
|
163
163
|
|
|
164
164
|
<Form method="post" action="/blog/new">
|
|
165
165
|
<input name="title" />
|
|
@@ -195,7 +195,7 @@ export default function BlogLayout() {
|
|
|
195
195
|
| `useFetcher()` | `{ data, state, load, submit }` | Background fetch without navigation |
|
|
196
196
|
|
|
197
197
|
```tsx
|
|
198
|
-
import { useLoaderData, useNavigation, useFetcher } from "bractjs";
|
|
198
|
+
import { useLoaderData, useNavigation, useFetcher } from "@bractjs/bractjs";
|
|
199
199
|
|
|
200
200
|
const { post } = useLoaderData<LoaderData>();
|
|
201
201
|
|
|
@@ -213,7 +213,7 @@ fetcher.load("/api/suggestions?q=bun");
|
|
|
213
213
|
`<Image>` serves responsively-sized, format-converted images through a built-in `/_image` endpoint. Requires [ImageMagick](https://imagemagick.org) (`magick` or `convert`) — falls back to serving the original if not installed.
|
|
214
214
|
|
|
215
215
|
```tsx
|
|
216
|
-
import { Image } from "bractjs";
|
|
216
|
+
import { Image } from "@bractjs/bractjs";
|
|
217
217
|
|
|
218
218
|
// Basic — lazy, WebP, 80% quality, responsive srcset
|
|
219
219
|
<Image src="/public/hero.jpg" alt="Hero" width={1200} height={600} />
|
|
@@ -363,7 +363,7 @@ export function Counter() {
|
|
|
363
363
|
Middleware runs before routing. Register on the module-level `pipeline` singleton.
|
|
364
364
|
|
|
365
365
|
```ts
|
|
366
|
-
import { pipeline, requestLogger, cors, authGuard } from "bractjs";
|
|
366
|
+
import { pipeline, requestLogger, cors, authGuard } from "@bractjs/bractjs";
|
|
367
367
|
|
|
368
368
|
pipeline
|
|
369
369
|
.use(requestLogger())
|
|
@@ -380,7 +380,7 @@ pipeline
|
|
|
380
380
|
**Custom middleware:**
|
|
381
381
|
|
|
382
382
|
```ts
|
|
383
|
-
import type { MiddlewareFn } from "bractjs";
|
|
383
|
+
import type { MiddlewareFn } from "@bractjs/bractjs";
|
|
384
384
|
|
|
385
385
|
const trace: MiddlewareFn = async (ctx, next) => {
|
|
386
386
|
ctx.context.requestId = crypto.randomUUID();
|
|
@@ -395,7 +395,7 @@ const trace: MiddlewareFn = async (ctx, next) => {
|
|
|
395
395
|
## Sessions
|
|
396
396
|
|
|
397
397
|
```ts
|
|
398
|
-
import { createCookieSession } from "bractjs";
|
|
398
|
+
import { createCookieSession } from "@bractjs/bractjs";
|
|
399
399
|
|
|
400
400
|
const session = createCookieSession({
|
|
401
401
|
name: "__session",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bractjs/bractjs",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"description": "Production-grade SSR framework for Bun + React 19. File-based routing, streaming SSR, server actions, typed routes.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://github.com/bractjs/bractjs#readme",
|
|
@@ -23,6 +23,9 @@
|
|
|
23
23
|
"typescript",
|
|
24
24
|
"full-stack"
|
|
25
25
|
],
|
|
26
|
+
"publishConfig": {
|
|
27
|
+
"access": "public"
|
|
28
|
+
},
|
|
26
29
|
"files": [
|
|
27
30
|
"src",
|
|
28
31
|
"bin",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { useLoaderData } from "bractjs";
|
|
2
|
-
import type { LoaderArgs } from "bractjs";
|
|
3
|
-
import { Link } from "bractjs";
|
|
1
|
+
import { useLoaderData } from "@bractjs/bractjs";
|
|
2
|
+
import type { LoaderArgs } from "@bractjs/bractjs";
|
|
3
|
+
import { Link } from "@bractjs/bractjs";
|
|
4
4
|
|
|
5
5
|
interface HomeData {
|
|
6
6
|
message: string;
|