reactHonoStarterREADME.md4 matches
1# React Hono Starter
23This app is a starter template for client-side React and server-side Hono.
45- **Remix** this starter template on the top right to get started.
7- The **entrypoint** is `/backend/index.ts`. That's the backend HTTP server, which also serves the all the frontend assets.
89- The **client-side entrypoint** is `/frontend/index.html`, which in turn imports `/frontend/index.tsx`, which in turn imports the React app from `/frontend/components/App.tsx`.
1011[React Hono Example](https://www.val.town/x/stevekrouse/reactHonoExample) is a fuller featured example project, with a SQLite database table, queries, client-side CSS and a favicon, and some shared code that runs on both client and server.
reactHonoStarterindex.html1 match
4<meta charset="UTF-8">
5<meta name="viewport" content="width=device-width, initial-scale=1.0">
6<title>React Hono Val Town Starter</title>
7<link rel="stylesheet" href="/public/style.css">
8<link rel="icon" href="/public/favicon.svg" sizes="any" type="image/svg+xml">
reactHonoStarterApp.tsx3 matches
1/** @jsxImportSource https://esm.sh/react@18.2.0 */
2import { useState } from "https://esm.sh/react@18.2.0";
34export function App() {
6return (
7<div>
8<h1>Val Town React + Hono Starter</h1>
9I've been clicked <button onClick={() => setClicked((c) => c + 1)}>{clicked}</button> times
10</div>
cerebras_coderindex10 matches
1/** @jsxImportSource https://esm.sh/react@18.2.0 */
2import { createRoot } from "https://esm.sh/react-dom@18.2.0/client?deps=react@18.2.0";
3import { Prism as SyntaxHighlighter } from "https://esm.sh/react-syntax-highlighter?deps=react@18.2.0,react-dom@18.2.0";
4import React, { useEffect, useState } from "https://esm.sh/react@18.2.0";
5import STARTER_PROMPTS from "./starter-prompts.js";
630}: {
31prompt: string;
32setPrompt: React.Dispatch<React.SetStateAction<string>>;
33handleSubmit: (e: React.FormEvent) => void;
34handleStarterPromptClick: (promptItem: PromptItem) => void;
35}) {
116117function App() {
118const previewRef = React.useRef<HTMLDivElement>(null);
119const [prompt, setPrompt] = useState("");
120const [projectId, setProjectId] = useState<number | null>(null);
174}
175176async function handleSubmit(e: React.FormEvent | string) {
177if (typeof e !== "string") {
178e.preventDefault();
673</div>
674<div className="bg-white w-full h-full flex flex-col grow rounded-xl border-2 border-white overflow-hidden">
675<React.Fragment key={iframeKey}>
676<iframe
677srcDoc={code}
679className="w-full grow"
680/>
681</React.Fragment>
682</div>
683</div>
1/** @jsxImportSource https://esm.sh/react */
2import React, { useEffect, useRef, useState } from "https://esm.sh/react";
3import { createRoot } from "https://esm.sh/react-dom/client";
4import ReactMarkdown from "https://esm.sh/react-markdown@9.0.1";
5import { Prism as SyntaxHighlighter } from "https://esm.sh/react-syntax-highlighter@15.5.0";
6import { oneDark } from "https://esm.sh/react-syntax-highlighter@15.5.0/dist/esm/styles/prism";
7import remarkGfm from "https://esm.sh/remark-gfm@4.0.0";
827return (
28<div style={role === "user" ? styles.userMessage : styles.assistantMessage}>
29<ReactMarkdown
30remarkPlugins={[remarkGfm]}
31components={{
67>
68{content}
69</ReactMarkdown>
70</div>
71);
1/** @jsxImportSource https://esm.sh/preact@10.19.6 */
2import { type ClassValue, clsx } from "https://esm.sh/clsx@2.1.0";
3import { Copy, QrCode, Send, Shield, Users } from "https://esm.sh/lucide-preact@0.358.0";
4import { Peer } from "https://esm.sh/peerjs@1.5.4?bundle-deps";
5import { render } from "https://esm.sh/preact@10.19.6";
6import { useEffect, useRef, useState } from "https://esm.sh/preact@10.19.6/hooks";
78interface NDEFRecord {
artisticApricotMackerelmain.tsx3 matches
1/** @jsxImportSource https://esm.sh/react@18.2.0 */
2import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
3import React from "https://esm.sh/react@18.2.0";
45function LinkInBio() {
ReactStreammain.tsx16 matches
1/** @jsxImportSource https://esm.sh/react@18.3.1 */
2import { hydrateRoot } from "https://esm.sh/react-dom@18.3.1/client";
3import * as React from "https://esm.sh/react@18.3.1";
45export { React };
67export type RequestHandler = (request: Request) => Promise<Response>;
13export type Middleware = (req: DataRequest, res: Response, callback: NextCallback) => Promise<Response>;
1415export interface ReactStreamProps {
16url: URL;
17pathname: string;
2324export function render<T>(
25/** Root-level React component that renders an entire <html> element
26* including the head and body tags.
27*/
28Component: React.ComponentType<ReactStreamProps>,
29/** On Val Town, use `import.meta.url` for client-side hydration */
30module: string | false,
31/** Optional middleware */
32opts: ReactStreamOptions | Middleware[] = [],
33) {
34const useMiddleware = Array.isArray(opts); // for backwards compat
35const options: ReactStreamOptions = !Array.isArray(opts) ? opts : {};
36const { api, getInitialProps } = options;
374243return async function handler(request: Request): Promise<Response> {
44const main = reactStream(Component, module);
45const middleware: Middleware[] = [
46parseURL,
71export default render;
7273// main react response handler
74const reactStream = (
75Component: React.ComponentType<ReactStreamProps>,
76module: string | false,
77): Middleware =>
78async function(req: DataRequest, res: Response): Promise<Response> {
79const { renderToReadableStream } = await import("https://esm.sh/react-dom@18.3.1/server");
8081const stream = await renderToReadableStream(
91headers.set("Content-Type", "text/html");
9293console.log("react", res.status);
94return new Response(stream, {
95headers,
139};
140/** DEPRECATED: Use middleware instead */
141export interface ReactStreamOptions {
142/** DEPRECATED: Optional text response for robots.txt */
143robots?: string;
sdfsdfsdfsjxnReactStream16 matches
1/** @jsxImportSource https://esm.sh/react@18.3.1 */
2import { hydrateRoot } from "https://esm.sh/react-dom@18.3.1/client";
3import * as React from "https://esm.sh/react@18.3.1";
45export { React };
67export type RequestHandler = (request: Request) => Promise<Response>;
13export type Middleware = (req: DataRequest, res: Response, callback: NextCallback) => Promise<Response>;
1415export interface ReactStreamProps {
16url: URL;
17pathname: string;
2324export function render<T>(
25/** Root-level React component that renders an entire <html> element
26* including the head and body tags.
27*/
28Component: React.ComponentType<ReactStreamProps>,
29/** On Val Town, use `import.meta.url` for client-side hydration */
30module: string | false,
31/** Optional middleware */
32opts: ReactStreamOptions | Middleware[] = [],
33) {
34const useMiddleware = Array.isArray(opts); // for backwards compat
35const options: ReactStreamOptions = !Array.isArray(opts) ? opts : {};
36const { api, getInitialProps } = options;
374243return async function handler(request: Request): Promise<Response> {
44const main = reactStream(Component, module);
45const middleware: Middleware[] = [
46parseURL,
71export default render;
7273// main react response handler
74const reactStream = (
75Component: React.ComponentType<ReactStreamProps>,
76module: string | false,
77): Middleware =>
78async function(req: DataRequest, res: Response): Promise<Response> {
79const { renderToReadableStream } = await import("https://esm.sh/react-dom@18.3.1/server");
8081const stream = await renderToReadableStream(
91headers.set("Content-Type", "text/html");
9293console.log("react", res.status);
94return new Response(stream, {
95headers,
139};
140/** DEPRECATED: Use middleware instead */
141export interface ReactStreamOptions {
142/** DEPRECATED: Optional text response for robots.txt */
143robots?: string;
sdfsdfsdfsjxnredirects2 matches
1import { match, parse, pathToRegexp } from "https://esm.sh/path-to-regexp@7.2.0";
2import { DataRequest } from "./ReactStream";
34const redirects = new Map();
5redirects.set("/hello-color", "https://jxnblk.io/hello-color");
6redirects.set("/react-icons", "https://jxnblk.io/react-icons/");
78redirects.set("/colorable", "https://colorable.jxnblk.com");