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/?q=react&page=369&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 4495 results for "react"(471ms)

mynewprojectjxnrss1 match

@stevekrouse•Updated 1 month ago
2
3// import data from "https://blog.jxnblk.com/api/all.json" with { type: "json" };
4import type { Middleware } from "https://esm.town/v/jxnblk/ReactStream";
5
6function generateRSSFeed(posts) {

mynewprojectjxnredirects2 matches

@stevekrouse•Updated 1 month ago
1import { match, parse, pathToRegexp } from "https://esm.sh/path-to-regexp@7.2.0";
2import { DataRequest } from "./ReactStream";
3
4const redirects = new Map();
5redirects.set("/hello-color", "https://jxnblk.io/hello-color");
6redirects.set("/react-icons", "https://jxnblk.io/react-icons/");
7
8redirects.set("/colorable", "https://colorable.jxnblk.com");

mynewprojectjxnReactStream16 matches

@stevekrouse•Updated 1 month ago
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";
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;

OpenTowniesystem_prompt.txt9 matches

@loading•Updated 1 month ago
107- **Storage Strategy:** Only use backend storage if explicitly required; prefer simple static client-side sites
108- For persistence, use Val Town SQLite or Blob storage with `import.meta.url` for keys/table names
109- **React Configuration:** When using React libraries, pin versions with `?deps=react@18.2.0,react-dom@18.2.0` and include the `@jsxImportSource` pragma
110- When facing client-side render issues, check if all React dependencies are pinned to the same version
111- **Styling:** Default to using TailwindCSS via `<script src="https://cdn.twind.style" crossorigin></script>` unless otherwise specified
112
220
221### Frontend Best Practices
222- Structure as a standard client-side React app
223- Use SVG for favicons (Val Town only supports text files)
224- Separate components into individual files
225- Access bootstrapped data from `window.__INITIAL_DATA__`
226- Use React 18.2.0 consistently in all imports and the `@jsxImportSource` pragma
227- Follow the React component pattern from the example project
228- Handle API calls properly with proper error catching
229
247 - Always run table creation before querying
248
2493. **React Configuration:**
250 - All React dependencies must be pinned to 18.2.0
251 - Always include `@jsxImportSource https://esm.sh/react@18.2.0` at the top of React files
252 - Rendering issues often come from mismatched React versions
253
2544. **File Handling:**

OpenTownieREADME.md1 match

@loading•Updated 1 month ago
8
9- [ ] Give it all the code (except maybe .txt files) as initial context (like cursor sonnet max)
10- [ ] Rebuild as React Router?
11- [ ] Persistent threads?
12- [ ] opentownie as a pr bot

OpenTownieindex.tsx2 matches

@loading•Updated 1 month ago
1/** @jsxImportSource https://esm.sh/react@18.2.0?dev */
2import { createRoot } from "https://esm.sh/react-dom@18.2.0/client?dev";
3import { App } from "./components/App.tsx";
4

OpenTownieImageUpload.tsx7 matches

@loading•Updated 1 month ago
1/** @jsxImportSource https://esm.sh/react@18.2.0?dev */
2import React, { useRef, useState } from "https://esm.sh/react@18.2.0?dev";
3
4// Maximum number of images that can be uploaded
15
16 // Handle file selection
17 const handleFileChange = (e: React.ChangeEvent<HTMLInputElement>) => {
18 if (e.target.files) {
19 processFiles(Array.from(e.target.files));
66
67 // Handle drag events
68 const handleDragEnter = (e: React.DragEvent) => {
69 e.preventDefault();
70 e.stopPropagation();
72 };
73
74 const handleDragLeave = (e: React.DragEvent) => {
75 e.preventDefault();
76 e.stopPropagation();
78 };
79
80 const handleDragOver = (e: React.DragEvent) => {
81 e.preventDefault();
82 e.stopPropagation();
83 };
84
85 const handleDrop = (e: React.DragEvent) => {
86 e.preventDefault();
87 e.stopPropagation();

OpenTownieCreateBranch.tsx3 matches

@loading•Updated 1 month ago
1/** @jsxImportSource https://esm.sh/react@18.2.0?dev */
2import React, { useState } from "https://esm.sh/react@18.2.0?dev";
3
4interface CreateBranchProps {
25 };
26
27 const handleSubmit = async (e: React.FormEvent) => {
28 e.preventDefault();
29

OpenTownieBranchControl.tsx3 matches

@loading•Updated 1 month ago
1/** @jsxImportSource https://esm.sh/react@18.2.0?dev */
2import React, { useEffect, useState } from "https://esm.sh/react@18.2.0?dev";
3import { CreateBranch } from "./CreateBranch.tsx";
4
84
85 // Handle branch selection change
86 const handleBranchChange = (e: React.ChangeEvent<HTMLSelectElement>) => {
87 const newBranchId = e.target.value;
88 setBranchId(newBranchId);

md_crawlindex.tsx3 matches

@stevekrouse•Updated 1 month ago
1// @jsxImportSource https://esm.sh/react@18.2.0
2import React from "https://esm.sh/react@18.2.0";
3import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
4import { App } from "./components/App";
5

react-router-starter-remix-13 file matches

@jxnblk•Updated 1 day ago

reactHonoStarter4 file matches

@stfnsr•Updated 2 days ago