![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
@bunpmjs/bunext
Advanced tools
compatible Runtime: bun 1.1.0 - 1.1.43 compatible OS: Linux, WSL
compatible Runtime: bun 1.1.0 - 1.1.43 compatible OS: Linux, WSL
N.B : Bun is in continuous change and compatibility between version is a
problem for Bunext there is possible crash over some new version of Bun.
I will keep up to date the framework for what it needs
Nextjs inspired Framework compatible with Bun Runtime
Facing problems? Open an issue
When an update of Bunext is made you must run:
#!/usr/bin/env bash
# this is temporary and will change in future release
bun bunext init
bun run db:create # only create the types
Documentation
React 19 & React Compiler
SQlite performance & features
Windows compatibility
Multi-Thread Http Worker ( bun ^1.1.25 & Linux only )
process.env ( Client + Server & Only Server )
SSR and CSR
layout stacking
React
Static assets
Server components ("use server" & "use client")
Revalidate ( Beta )
Server action ( File, File[] and FormData can be uploaded )
Session Management ( public & private )
SQlite Management ( Beta )
Server components ( Beta )
Développement mode with Hot Reload ( beta version )
Production mode ( Beta )
Links
SVG support
#!/bin/env bash
bun i @bunpmjs/bunext || bunpm install bunext
bun bunext init
bun run dev
#!/bin/env bash
bun run build # this just make sure your build folder is created and ready to start
bun run start # Enjoy!!!
Here is the summary of the framework docs. I will soon make a website making it more simple, clear and fun to read. Thanks to all people how are following my work!
Like NextJs the routes are in src/pages.
//index.tsx
export default function Page() {
return <div>My page</div>
}
//[action]/[id].tsx
type Params = {
action: string;
id: string;
};
export default function DynamicPage({params}:{params: Params}) {
return (
<div>
action: {params.action}
id: {params.id}
</div>
);
}
two methods to navigate to another page
// index.tsx
import { navigate, Link } from "@bunpmjs/bunext/internal/router";
function NextPage() {
return <>
<button onClick={() => navigate("/new/location")}>Next page</button>
<Link href="/new/location">
<button>Next Page</button>
</Link>
</>;
}
Manage the session from your users by setting a session and optionally make it accessible from the client side ( default to only Server Side ).
SetData only from the Server Side is allowed.
Delete Session data can be Client or Server Side
GetData can be Client or Server Side ( but Client only have access to what is made public )
import { GetSession, useSession } from "@bunpmjs/bunext/features/session";
export default function Page() {
return (
<div>
<LoggedIndicator />
<SetSession />
</div>
);
}
type SessionType = {
username: string
};
function SetSession() {
const session = useSession<SessionType>({
PreventRenderOnUpdate: true,
});
return (
<button
onClick={async () => {
await ServerSetSession({
username: "foo",
password: "bar",
});
session.update();
/*
Will update every React Element using useSession
without PreventRenderOnUpdate
*/
}}
>
Click to update Session
</button>
);
}
function LoggedIndicator() {
const session = useSession();
return (<span>
{session.getData()?.username ? `logged as ${session.getData().username}` : "not logged"}
</span>);
}
export async function ServerSetSession({
username,
password,
}: {
username: string;
password: string;
}) {
const Session = GetSession(arguments);
Session.setData(
{
username: username,
},
true
); // accessed from Client & Server Side
Session.setData(
{
password: password,
},
false
); // Only accessed from Server Side
}
import { useSession } from "@bunpmjs/bunext/features/session";
export default function Page() {
return <div>
<ReactElement />
</div>
}
type SessionType = {
username: string
};
function ReactElement() {
const session = useSession<SessionType>();
return <span>{session.getData()?.username || "not logged"}</span>
}
// index.tsx
import {
useSession,
GetSession
} from "@bunpmjs/bunext/features/session";
export default function Page() {
return <div>
<ReactElement />
</div>
}
type SessionType = {
username: string
};
// using a JS event from a React Element
function ReactElement() {
const session = useSession<SessionType>();
return <button onClick={() => session.delete()}>Click to delete the session</button>
}
// using a serverAction
export async function ServerDeleteSession() {
GetSession(arguments).delete();
return "Session has been deleted by the server"
}
// using an API endpoint
export function GET(request: BunextRequest) {
GetSession(arguments).delete();
request.response = new Response("Session Deleted");
return request;
}
Like Next offer a ServerAction method Bunext does it as well. Key informations:
// index.tsx
export default function FormPage() {
return (
<form
onSubmit={async (e) => {
e.preventDefault();
const form = new FormData(e.currentTarget);
const res = await ServerUploadFile(
{
username: form.get("username") as string,
password: form.get("password") as string,
},
form.get("file") as File
);
alert(JSON.stringify(res));
}}
>
<input type="file" name="file" />
<input type="text" placeholder="username" name="username" />
<input type="text" placeholder="password" name="password" />
<button type="submit">Send</button>
</form>
);
}
export async function ServerUploadFile(
{
username,
password,
}: {
username: string;
password: string;
},
file: File
) {
// do stuff
await Bun.write("path/" + file.name, file);
return {
success: true,
message: "file saved successful",
};
}
Bunext offer a Server Components ability that is managed with revalidate. Will run only once at build time and when revalidate is ran.
// index.tsx
export default async function Page() {
return (
<div>
{await Components()}
<NotValid />
</div>
);
}
// valid Server Component
export async function Components() {
const res = await (await fetch("https://some-api.com/api")).json();
return <div>{JSON.stringify(res)}</div>;
}
// not valid Server Component
export function NotValid({ someProps }: { someProps: string }) {
return <div></div>;
}
// index.tsx
import { revalidateEvery, revalidate } from "@bunpmjs/bunext/features/router";
export default function Page() {
revalidateEvery("/", 3600);
// will revalidate the page at every 3600 second
return <div>
<button onClick={() => ServerRevalidate("/")}>Revalidate / path</button>
</div>;
}
export async function ServerRevalidate(paths: string[]) {
await revalidate(...paths);
// will revalidate all pages in paths right now
}
Load dynamic data directly into the main React Element.
type Props = {
foo: string;
name: {
john: string;
}
};
type Params = {
action: string;
id: string;
}
// [action]/[id].tsx
export default function Page({props, params}: {
props: Props
params: Params
}) {
return <div>{props.foo + " - " + params.id}</div>
}
export async function getServerSideProps(): Props {
// go get some api data, database, etc...
// return { redirect: "/path/to/another/location" };
// will redirect to a different location
return {
foo: "bar",
name: {
john: "Doe"
}
};
}
In /config/database.ts is for the database Schema.
this is pretty much a basic structure that will make type safe your database call.
Exemple:
import { Union } from "@bunpmjs/bunext/database/schema";
const MyDatabaseShema: DBSchema = [
{
name: "Users",
columns: [
{
name: "id",
type: "number",
unique: true,
autoIncrement: true,
primary: true,
},
{
name: "username",
unique: true,
type: "string",
},
{
name: "role",
type: "string",
union: ["admin", "user"]
},
{
name: "info",
type: "json",
DataType: {
cart: [{
type: Union("drink", "food", "other"),
quantity: "number",
}]
},
},
],
},
];
export default MyDatabaseShema;
run this script
#!/bin/bash
bun run db:create
Database is only allowed in Server Side
// index.tsx
import { Database } from "@bunpmjs/bunext/database";
//in a Server Component
export async function ReactElement() {
const db = Database();
return (
<div>
{db.tableName
.select({
select: {
column1: true,
column2: true,
},
where: {
OR: [
{
column1: "foo",
column2: "bar",
},
{
column1: "fizz",
column2: "buzz",
},
],
},
})
.map((row) => {
/*...doStuff*/
})}
</div>
);
}
// /index.tsx
import { Head } from "@bunpmjs/bunext/features/head";
Head.setHead({
data: {
author: "John Doe",
title: "my Home-page",
publisher: "Bunext",
meta: [
{
name: "foo",
content: "bar",
},
],
link: [
{
rel: "stylesheet",
href: "main.css"
}
]
},
path: "/otherPath",
});
use svg file as component you can import
// index.tsx
import SVGIcon from "./my-svg.svg";
export default function Page() {
return (
<div>
{SVGIcon()}
<Element />
</div>
);
}
function Element() {
return <SVGIcon className="icon" />
}
config/preload.ts will run at startup
config/server.ts contain server related configuration
To make a custom Response in config/onRequest.ts, return (Response or async Response) to bypass the default behavior, or return undefined to use the default behavior.
import type { BunextRequest } from "@bunpmjs/bunext/features/request";
// /src/pages/api/v1/index.ts
export function POST(request: BunextRequest) {
request.response = new Response("POST");
return request;
}
export function GET(request: BunextRequest) {
request.response = new Response("GET");
return request;
}
export function PUT(request: BunextRequest) {
request.response = new Response("PUT");
return request;
}
export function DELETE(request: BunextRequest) {
request.response = new Response("DELETE");
return request;
}
// Client request
await fetch("my.site.com/api/v1", {
method: "POST",
body: JSON.stringify({ foo: "bar" })
}); // return the post data
An environment variable can be set as public and accessed in a client context if the key starts with PUBLIC
PUBLIC_API_KEY="some-public-api-key"
API_KEY="private-api-key"
Computer specs:
env variables can be made public by adding PUBLIC keyword. Ex: PUBLIC_API_KEY="abcdefghijklmnop12345678" // can be accessed from client and server API_KEY="abcdefghijklmnop12345678" // only accessed from server side
css can now be loaded directly in the page as a link in /static path
@static path is now accessible to directly access /static path
FAQs
compatible Runtime: bun 1.1.0 - 1.1.43 compatible OS: Linux, WSL
The npm package @bunpmjs/bunext receives a total of 0 weekly downloads. As such, @bunpmjs/bunext popularity was classified as not popular.
We found that @bunpmjs/bunext demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.