Val Town Code SearchReturn to Val Town

API Access

You can access search results via JSON API by adding format=json to your query:

https://codesearch.val.run/$%7Bart_info.art.src%7D?q=react&page=834&format=json

For typeahead suggestions, use the /typeahead endpoint:

https://codesearch.val.run/typeahead?q=react

Returns an array of strings in format "username" or "username/projectName"

Found 8980 results for "react"(3004ms)

ReactStreamREADME.md15 matches

@lisardoUpdated 8 months ago
1React SSR and client-side hydration for Val Town
2
3## Usage
4
5```tsx
6/** @jsxImportSource https://esm.sh/react */
7import { render, React } from "https://esm.town/v/jxnblk/ReactStream";
8
9function App() {
10 const [count, setCount] = React.useState(0);
11 return (
12 <html>
13 <body>
14 <h1>ReactStream</h1>
15 <p>React SSR with client-side hydration in Val Town</p>
16 <pre>{count}</pre>
17 <button onClick={() => setCount(count - 1)}>-</button>
25```
26
27[Live example](https://www.val.town/v/jxnblk/ReactStreamDemo)
28
29To render static HTML without hydration, pass `false` as the second argument.
48### robots.txt
49
50ReactStream has a built-in middleware to handle request to `/robots.txt`
51
52```tsx
53import { render, robots } from "https://esm.town/v/jxnblk/ReactStream";
54// ...
55export default render(App, import.meta.url, [
92
93```tsx
94/** @jsxImportSource https://esm.sh/react */
95import { render } from "https://esm.town/v/jxnblk/ReactStream";
96
97function App () {
99 <html>
100 <head>
101 <title>ReactStream</title>
102 </head>
103 <body>
111```
112
113React requires matching versions for SSR and hydration.
114Import `React` from `https://esm.town/v/jxnblk/ReactStream` to ensure your component uses the same version as this library (currently react@18.3.1).
115
116Inspired by https://www.val.town/v/stevekrouse/react_http & https://www.val.town/v/stevekrouse/reactClientDemo
117

ReactStreammain.tsx16 matches

@lisardoUpdated 8 months ago
1/** @jsxImportSource https://esm.sh/react */
2import { hydrateRoot } from "https://esm.sh/react-dom@18.3.1/client";
3import * as React from "https://esm.sh/react@18.3.1";
4
5export { React };
6
7export type RequestHandler = (request: Request) => Promise<Response>;
13export type Middleware = (req: DataRequest, res: Response, callback: NextCallback) => Promise<Response>;
14
15export interface ReactStreamProps {
16 url: URL;
17 pathname: string;
23
24export function render<T>(
25 /** Root-level React component that renders an entire <html> element
26 * including the head and body tags.
27 */
28 Component: React.ComponentType<ReactStreamProps>,
29 /** On Val Town, use `import.meta.url` for client-side hydration */
30 module: string | false,
31 /** Optional middleware */
32 opts: ReactStreamOptions | Middleware[] = [],
33) {
34 const useMiddleware = Array.isArray(opts); // for backwards compat
35 const options: ReactStreamOptions = !Array.isArray(opts) ? opts : {};
36 const { api, getInitialProps } = options;
37
42
43 return async function handler(request: Request): Promise<Response> {
44 const main = reactStream(Component, module);
45 const middleware: Middleware[] = [
46 parseURL,
71export default render;
72
73// main react response handler
74const reactStream = (
75 Component: React.ComponentType<ReactStreamProps>,
76 module: string | false,
77): Middleware =>
78 async function(req: DataRequest, res: Response): Promise<Response> {
79 const { renderToReadableStream } = await import("https://esm.sh/react-dom@18.3.1/server");
80
81 const stream = await renderToReadableStream(
91 headers.set("Content-Type", "text/html");
92
93 console.log("react", res.status);
94 return new Response(stream, {
95 headers,
139};
140/** DEPRECATED: Use middleware instead */
141export interface ReactStreamOptions {
142 /** DEPRECATED: Optional text response for robots.txt */
143 robots?: string;

hungryWhiteLeoponmain.tsx4 matches

@gr8gatsbyUpdated 8 months ago
4 * information in a SQLite database. The app provides a user interface to view, add, and edit coffee shop reviews.
5 *
6 * It uses React for the frontend, the Nominatim API for initial coffee shop data,
7 * and Val Town's SQLite for data persistence.
8 */
9
10/** @jsxImportSource https://esm.sh/react */
11import React, { useEffect, useState } from "https://esm.sh/react";
12import { createRoot } from "https://esm.sh/react-dom/client";
13
14function App() {

addToLogmain.tsx5 matches

@ejfoxUpdated 8 months ago
1/**
2 * This chat application allows users to post messages and view a log of all messages.
3 * It uses SQLite for persistence and React for the frontend.
4 * The server handles message posting and retrieval, while the client renders the UI.
5 */
6/** @jsxImportSource https://esm.sh/react */
7import React, { useState, useEffect } from "https://esm.sh/react";
8import { createRoot } from "https://esm.sh/react-dom/client";
9
10interface Message {
28 };
29
30 const handleSubmit = async (e: React.FormEvent) => {
31 e.preventDefault();
32 if (!newMessage.trim()) return;

inventorymain.tsx6 matches

@ejfoxUpdated 8 months ago
1/**
2 * This val creates an interactive tech stack wizard that generates a video game-style inventory screen.
3 * It uses React for the UI, leverages emoji and Unicode symbols for a visually rich experience, and
4 * incorporates Tailwind CSS for elegant, grayscale styling.
5 * The wizard allows users to select tools, libraries, and APIs, then displays them in a shareable format.
6 */
7
8/** @jsxImportSource https://esm.sh/react */
9import React, { useState } from "https://esm.sh/react";
10import { createRoot } from "https://esm.sh/react-dom/client";
11
12// Define tech options with emojis or Unicode symbols as icons
13const techOptions = [
14 { name: "React", icon: "⚛️" },
15 { name: "Vue", icon: "🖖" },
16 { name: "Angular", icon: "🅰️" },
47 { name: "Swift", icon: "🕊️" },
48 { name: "Flutter", icon: "🦋" },
49 { name: "React Native", icon: "📱" },
50 { name: "Electron", icon: "🔬" },
51 { name: "Webpack", icon: "📦" },

techstackinventorymain.tsx5 matches

@ejfoxUpdated 8 months ago
1/**
2 * This val creates a tech stack inventory chooser using React and Tailwind CSS for styling.
3 * It allows users to select technologies for different categories and displays the chosen stack.
4 */
5/** @jsxImportSource https://esm.sh/react */
6import React, { useState } from "https://esm.sh/react";
7import { createRoot } from "https://esm.sh/react-dom/client";
8
9const techCategories = {
10 frontend: ["React", "Vue", "Angular", "Svelte"],
11 backend: ["Node.js", "Python", "Ruby", "Java"],
12 database: ["PostgreSQL", "MongoDB", "MySQL", "SQLite"],

homepagemain.tsx3 matches

@csl_Updated 8 months ago
5 */
6
7/** @jsxImportSource https://esm.sh/react */
8import React, { useEffect, useState } from "https://esm.sh/react";
9import { createRoot } from "https://esm.sh/react-dom/client";
10
11function App() {

statusmain.tsx3 matches

@endzelUpdated 8 months ago
1/** @jsxImportSource https://esm.sh/react */
2import { sqlite } from "https://esm.town/v/std/sqlite?v=6";
3import { html } from "https://esm.town/v/stevekrouse/html";
4import { SparklineSVG } from "https://esm.town/v/stevekrouse/sparklineSVGReact";
5import { renderToString } from "npm:react-dom/server";
6
7function StatusRow({ rows }) {

shySapphireLeopardmain.tsx4 matches

@stevekrouseUpdated 8 months ago
1/** @jsxImportSource https://esm.sh/react */
2import { renderToString } from "npm:react-dom/server";
3
4import React from "https://esm.sh/react";
5import { createRoot } from "https://esm.sh/react-dom/client";
6
7function App() {

valleGetValsContextWindowmain.tsx9 matches

@roadlabsUpdated 8 months ago
41 {
42 type: "http",
43 prompt: "Generate a val that uses React to render HTML",
44 code: `/** @jsxImportSource https://esm.sh/react */
45 import { renderToString } from "npm:react-dom/server";
46
47 export const reactExample = (request: Request) =>
48 new Response(renderToString(<div>Test {1 + 1}</div>), {
49 headers: {
74 type: "http",
75 prompt: null,
76 code: `/** @jsxImportSource https://esm.sh/preact */
77 import { render } from "npm:preact-render-to-string";
78
79 export const preactExample = (request: Request) =>
80 new Response(render(<div>Test {1 + 1}</div>), {
81 headers: {
191 prompt: "Write a val that renders a website and uses tailwind css",
192 type: "http",
193 code: `/** @jsxImportSource https://esm.sh/preact */
194 import { render } from "npm:preact-render-to-string";
195
196 export default async function(req: Request) {

vt-discord4 file matches

@boucherUpdated 3 days ago
Starter template with client-side React & Hono server

diceRollerUI1 file match

@dcm31Updated 3 days ago
A web-based dice roller using React on Val Town
effector
Write business logic with ease Meet the new standard for modern TypeScript development. Type-safe, reactive, framework-agnostic library to manage your business logic.
officialrajdeepsingh
Follow me if you learn more about JavaScript | TypeScript | React.js | Next.js | Linux | NixOS | Frontend Developer | https://linktr.ee/officialrajdeepsingh