Search
reacttldrawclient
@tfayyaz
@jsxImportSource https://esm.sh/react@18.2.0
Script
/** @jsxImportSource https://esm.sh/react@18.2.0 **/
// Make sure to only import from esm.sh (npm: specifier are not supported in the browser)
import ReactDOM from "https://esm.sh/react-dom@18.2.0";
import React from "https://esm.sh/react@18.0.0";
import { useState } from "https://esm.sh/react@18.0.0";
import { Tldraw } from "https://esm.sh/tldraw@2.1.0";
</div>
// The app will be rendered inside the root div
const root = ReactDOM.createRoot(document.getElementById("root"));
root.render(<App />);
kickstart_feedback
@bansal
@jsxImportSource https://esm.sh/react
HTTP
/** @jsxImportSource https://esm.sh/react */
import React, { useEffect, useState } from "https://esm.sh/react";
import { createRoot } from "https://esm.sh/react-dom/client";
interface AirtableRecord {
</div>
{/* Sidebar */}
<div className="flex flex-col sm:flex-row gap-6">
</div>
function client() {
createRoot(document.getElementById("root")).render(<AirtableList />);
if (typeof document !== "undefined") { client(); }
export default async function server(request: Request): Promise<Response> {
reacttldrawclient
@iamseeley
@jsxImportSource https://esm.sh/react
Script
/** @jsxImportSource https://esm.sh/react **/
// Make sure to only import from esm.sh (npm: specifier are not supported in the browser)
import ReactDOM from "https://esm.sh/react-dom";
import React, { useState, useEffect } from "https://esm.sh/react@18.0.0";
function TestComponent() {
</div>
// The app will be rendered inside the root div
const root = ReactDOM.createRoot(document.getElementById("root"));
root.render(<App />);
cerebras_coder
@ChuckYLeeVIII
This is an AI code assistant powered by Cerebras , running llama3.3-70b. Inspired by Hassan's Llama Coder . Setup Sign up for Cerebras Get a Cerebras API Key Save it in a Val Town environment variable called CEREBRAS_API_KEY Todos I'm looking for collaborators to help. Fork & send me PRs! [ ] Experiment with two prompt chain (started here )
HTTP
/** @jsxImportSource https://esm.sh/react@18.2.0 */
import React, { useState, useEffect, useRef } from "https://esm.sh/react@18.2.0";
import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
import Web3 from "https://esm.sh/web3@1.10.0";
initWeb3();
// Click outside tooltip handler
const handleClickOutside = (event) => {
if (tooltipRef.current && !tooltipRef.current.contains(event.target)) {
setShowTooltip(false);
document.addEventListener('mousedown', handleClickOutside);
return () => document.removeEventListener('mousedown', handleClickOutside);
useEffect(() => {
</div>
function client() {
createRoot(document.getElementById("root")).render(<App />);
if (typeof document !== "undefined") { client(); }
export default async function server(request: Request) {
TodoApp
@stevekrouse
SSR React Mini & SQLite Todo App This Todo App is server rendered and client-hydrated React. This architecture is a lightweight alternative to NextJS, RemixJS, or other React metaframeworks with no compile or build step. The data is saved server-side in Val Town SQLite . SSR React Mini Framework This "framework" is currently 44 lines of code, so it's obviously not a true replacement for NextJS or Remix. The trick is client-side importing the React component that you're server rendering . Val Town is uniquely suited for this trick because it both runs your code server-side and exposes vals as modules importable by the browser. The tricky part is making sure that server-only code doesn't run on the client and vice-versa. For example, because this val colocates the server-side loader and action with the React component we have to be careful to do all server-only imports (ie sqlite) dynamically inside the loader and action , so they only run server-side.
HTTP
# SSR React Mini & SQLite Todo App
This Todo App is server rendered *and* client-hydrated React. This architecture is a lightweight alternative to NextJS, RemixJS, or other React metaframeworks with no compile or build step. The data is saved server-side in [Val Town SQLite](https://docs.val.town/std/sqlite/).
## SSR React Mini Framework
This ["framework"](https://www.val.town/v/stevekrouse/ssr_react_mini) is currently 44 lines of code, so it's obviously not a true replacement for NextJS or Remix.
The trick is [client-side importing](https://www.val.town/v/stevekrouse/ssr_react_mini?v=53#L30) the React component that you're [server rendering](https://www.val.town/v/stevekrouse/ssr_react_mini?v=53#L35-37). Val Town is uniquely suited for this trick because it both runs your code server-side and exposes vals as [modules](https://esm.town/v/stevekrouse/TodoApp) importable by the browser.
The tricky part is making sure that server-only code doesn't run on the client and vice-versa. For example, because this val colocates the server-side `loader` and `action` with the React component we have to be careful to do all server-only imports (ie sqlite) dynamically inside the [`loader`](https://www.val.town/v/stevekrouse/TodoApp?v=246#L7) and [`action`](https://www.val.town/v/stevekrouse/TodoApp?v=246#L20), so they only run server-side.
/** @jsxImportSource https://esm.sh/react */
import { useEffect, useState } from "https://esm.sh/react@18.2.0";
import { Form, hydrate } from "https://esm.town/v/stevekrouse/ssr_react_mini?v=75";
useEffect(() => addLog(`Client rendered`), []);
MicroSaasIdeaRoulette
@heltonteixeira
@jsxImportSource https://esm.sh/react
HTTP
/** @jsxImportSource https://esm.sh/react */
import React, { useState, useEffect } from "https://esm.sh/react";
import { createRoot } from "https://esm.sh/react-dom/client";
function App() {
display: 'block',
function client() {
createRoot(document.getElementById("root")).render(<App />);
if (typeof document !== "undefined") { client(); }
export default async function server(request: Request): Promise<Response> {
fluxImageGenerator
@isidentical
Sign in to fal.ai, generate an API key, and set it as FAL_KEY for your account.
HTTP
// React is used for the UI and the fal.ai serverless client for image generation.
/** @jsxImportSource https://esm.sh/react */
import * as fal from "https://esm.sh/@fal-ai/serverless-client";
import React, { useEffect, useState } from "https://esm.sh/react";
import { createRoot } from "https://esm.sh/react-dom/client";
function client() {
client();
async function checkRateLimit(clientIP: string): Promise<boolean> {
const key = `xratelimit_${clientIP}`;
let clientData = await blob.getJSON<RateLimitData>(key);
soulfulPinkPinniped
@aanand700
@jsxImportSource https://esm.sh/react@18.2.0
HTTP
/** @jsxImportSource https://esm.sh/react@18.2.0 */
import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
import React, { useEffect, useState } from "https://esm.sh/react@18.2.0";
export default async function server(request: Request): Promise<Response> {
const TABLE_NAME = `${KEY}_assessments`;
// CSS definition moved inside the server function
const css = `
</div>
function client() {
createRoot(document.getElementById("root")).render(<App />);
if (typeof document !== "undefined") { client(); }
reacttldrawclient
@tmcw
@jsxImportSource https://esm.sh/react@18.2.0
Script
/** @jsxImportSource https://esm.sh/react@18.2.0 **/
// Make sure to only import from esm.sh (npm: specifier are not supported in the browser)
import ReactDOM from "https://esm.sh/react-dom@18.2.0";
import React from "https://esm.sh/react@18.2.0";
import { useState } from "https://esm.sh/react@18.2.0";
import { Tldraw } from "https://esm.sh/tldraw@2.1.0";
</div>
// The app will be rendered inside the root div
const root = ReactDOM.createRoot(document.getElementById("root"));
root.render(<App />);
windsurf_projectContext
@toowired
@jsxImportSource https://esm.sh/react@18.2.0
HTTP
/** @jsxImportSource https://esm.sh/react@18.2.0 */
import React, { useState, useEffect } from "https://esm.sh/react@18.2.0";
import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
* @returns {React.ReactElement}
* @returns {React.ReactElement}
* @param {React.FormEvent} e - The form event
* @returns {React.ReactElement}
* @param {React.FormEvent} e - The form event
* @returns {React.ReactElement}
* @param {React.FormEvent} e - The form event
lovableVioletLandfowl
@eligosmlytics
@jsxImportSource https://esm.sh/react
HTTP
/** @jsxImportSource https://esm.sh/react */
import React, { useState, useRef } from "https://esm.sh/react";
import { createRoot } from "https://esm.sh/react-dom/client";
function Popup({ isOpen, onClose, content }) {
</form>
<p className="note">Note: This tool uses the PageSpeed Insights API without authentication, which has usage limits. For higher quotas, consider using an API key.</p>
<div className="content-wrapper">
</div>
function client() {
createRoot(document.getElementById("root")).render(<App />);
if (typeof document !== "undefined") {
client();
export default async function server(request: Request): Promise<Response> {
eldestBronzePtarmigan
@ejfox
* This dating app allows users to upload photos of their bedside table and phone case.
* It uses Val Town's SQLite for data persistence and blob storage for image uploads.
* The app includes a simple matching algorithm based on common items in bedside tables.
HTTP
* This dating app allows users to upload photos of their bedside table and phone case.
* The app includes a simple matching algorithm based on common items in bedside tables.
/** @jsxImportSource https://esm.sh/react */
import React, { useState, useEffect } from "https://esm.sh/react";
import { createRoot } from "https://esm.sh/react-dom/client";
const [bedsideImage, setBedsideImage] = useState(null);
setBedsideImage(userData.bedsideImage);
if (type === 'bedside') {
setBedsideImage(result.imageUrl);
<h1>Bedside & Case Dating App</h1>
httpHelloWorld
@hugenshen
// This approach creates a PC application with a left-side menu structure as requested.
HTTP
// This approach creates a PC application with a left-side menu structure as requested.
// We'll use React for the UI components and React Router for navigation.
// The server will serve the HTML, and the client-side React application will handle the menu and routing.
/** @jsxImportSource https://esm.sh/react */
import ReactDOM from "https://esm.sh/react-dom@18.2.0";
import { BrowserRouter, Link, Route, Routes } from "https://esm.sh/react-router-dom@6.11.2";
import React from "https://esm.sh/react@18.2.0";
const [isOpen, setIsOpen] = React.useState(false);
const [isHovered, setIsHovered] = React.useState(false);
function client() {
resrv
@jxnblk
React SSR and client-side hydration for Val Town For streaming responses use ReactStream Usage /** @jsxImportSource https://esm.sh/react */
import resrv, { React } from "https://esm.town/v/jxnblk/resrv";
function App() {
const [count, setCount] = React.useState(0);
return (
<div>
<h1>Resrv</h1>
<p>React SSR with client-side hydration in Val Town</p>
<pre>{count}</pre>
<button onClick={() => setCount(count - 1)}>-</button>
<button onClick={() => setCount(count + 1)}>+</button>
</div>
);
}
export default resrv(App, import.meta.url); Live example React requires matching versions for SSR and hydration.
Import React from https://esm.town/v/jxnblk/resrv to ensure your component uses the same version as this library (currently react@18.3.1). HTML Root Hydration To render a component that includes a <head> and <body> tag, pass root: true to the third options argument: function App ({ script }) {
return (
<body>
<h1>Hello</h1>
{script}
</body>
);
}
export default resrv(App, import.meta.url, { root: true }); Inspired by https://www.val.town/v/stevekrouse/react_http
Script
React SSR and client-side hydration for Val Town
For streaming responses use [ReactStream]
[ReactStream]: https://www.val.town/v/jxnblk/ReactStream
/** @jsxImportSource https://esm.sh/react */
import { renderToString } from "https://esm.sh/react-dom@18.3.1/server";
import * as React from "https://esm.sh/react@18.3.1";
// import resrv, { React } from "https://esm.town/v/jxnblk/resrv";
export { React };
import { hydrateRoot } from "https://esm.sh/react-dom@18.3.1/client";
import { jsx } from "https://esm.sh/react@18.3.1/jsx-runtime";
VEOPROMPTER
@AppleLamps
@jsxImportSource https://esm.sh/react@18.2.0
HTTP
/** @jsxImportSource https://esm.sh/react@18.2.0 */
import { motion } from "https://esm.sh/framer-motion@10.16.4";
import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
import React, { useEffect, useState } from "https://esm.sh/react@18.2.0";
function App() {
<p className="text-lg font-semibold">How to Use:</p>
<ol className="list-decimal list-inside mt-2 space-y-1 text-sm">
<li>Write your idea in the text input field.</li>
</div>
function client() {
createRoot(document.getElementById("root")).render(<App />);
if (typeof document !== "undefined") {
client();
export default async function server(request: Request): Promise<Response> {
- Focus on the main subject or theme.
- Add relevant details to create a brief, yet descriptive prompt. Consider:
* Environment (e.g., forest, city, desert)
- Expand on the main subject or theme.
- Add a wide range of details to create a rich and immersive prompt. Consider:
* Environment: describe the setting, including terrain, climate, and atmosphere.
- Use descriptive language to paint a vivid picture, including adjectives, adverbs, and sensory details.
- Consider adding context or backstory to the scene, such as the characters' motivations or the environment's history.
Format your response as follows: