Request and Response
You can use request
inside Server Components, Server Functions, or their dependencies to access request details during server rendering or while running a Server Function.
tsx
import { request } from "react-just/server";
function Profile() {
const { url } = request();
// Use the URL to render the selected profile tab
const tab = getSelectedTab(url);
}
ts
"use server";
import { request } from "react-just/server";
export async function editPreferences() {
const { headers } = request();
// Use the cookie header to read the session
const session = await getSession(headers.get("cookie"));
}
You can use response
inside Server Functions or their dependencies to modify the HTTP response.
ts
"use server";
import { response } from "react-just/server";
export async function saveSettings() {
const { headers } = response();
// Set a cookie with rendering preferences
headers.append("Set-Cookie", getThemeSetCookie());
}
Visit the Server Utilities reference for more usage details.