Search
linkInBioTemplate
@hbcoop
@jsxImportSource https://esm.sh/react@17.0.2
HTTP
/** @jsxImportSource https://esm.sh/react@17.0.2 */
import { renderToString } from "https://esm.sh/react-dom@17.0.2/server";
import React from "https://esm.sh/react@17.0.2";
const gradientBackground: React.CSSProperties = {
background: "linear-gradient(135deg, #00a8e8 0%, #007ea7 100%)",
justifyContent: "center",
const containerStyle: React.CSSProperties = {
padding: "30px",
boxShadow: "0 10px 30px rgba(0, 0, 0, 0.1)",
const headingStyle: React.CSSProperties = {
color: "#ffffff",
marginBottom: "10px",
const subheadingStyle: React.CSSProperties = {
color: "#e0f7fa",
marginBottom: "20px",
const buttonContainerStyle: React.CSSProperties = {
display: "flex",
gap: "15px",
const buttonStyle: React.CSSProperties = {
padding: "12px",
socialMetaTest
@jesusgollonet
@jsxImportSource https://esm.sh/react
HTTP
/** @jsxImportSource https://esm.sh/react */
import { renderToString } from "npm:react-dom/server";
export default async function(req: Request) {
const description = "social meta test";
randomTextGenerator
@aleaf
@jsxImportSource https://esm.sh/react
HTTP
/** @jsxImportSource https://esm.sh/react */
import React, { useState } from "https://esm.sh/react";
import { createRoot } from "https://esm.sh/react-dom/client";
function App() {
</div>
function client() {
createRoot(document.getElementById("root")).render(<App />);
if (typeof document !== "undefined") { client(); }
export default async function server(request: Request): Promise<Response> {
perf
@stevekrouse
Perf - a website performance tester I had Anthropic build this for me to show off the launch of HTTP (Preview) vals: https://blog.val.town/blog/http-preview/
HTTP
/** @jsxImportSource https://esm.sh/react */
import pLimit from "https://esm.sh/p-limit";
import React, { useCallback, useState } from "https://esm.sh/react";
import { hydrateRoot } from "https://esm.sh/react-dom/client";
import { renderToReadableStream } from "https://esm.sh/react-dom/server";
import { extractValInfo } from "https://esm.town/v/pomdtr/extractValInfo";
: "N/A";
// React components
const TestForm = ({ onSubmit, isLoading }) => {
GeauxWeisbeck4_Introduction
@geauxweisbeck4
@jsxImportSource https://esm.sh/react@18.2.0
HTTP
/** @jsxImportSource https://esm.sh/react@18.2.0 */
import React from "https://esm.sh/react@18.2.0";
import { renderToString } from "https://esm.sh/react-dom@18.2.0/server";
export default (req: Request) => {
linkInBioTemplate
@djs
@jsxImportSource https://esm.sh/react
HTTP
/** @jsxImportSource https://esm.sh/react */
import { renderToString } from "npm:react-dom/server";
export default async function(req: Request) {
return new Response(
fifteenPuzzle
@manyone
@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 countInversions(board: number[]) {
textDecoration: 'none'
function client() {
createRoot(document.getElementById("root")).render(<SlidingPuzzle />);
if (typeof document !== "undefined") { client(); }
export default async function server(request: Request): Promise<Response> {
valTownChatGPT
@stevekrouse
ChatGPT Implemented in Val Town Demonstrated how to use assistants and threads with the OpenAI SDK and how to stream the response with Server-Sent Events
HTTP
/** @jsxImportSource https://esm.sh/react */
import OpenAI from "npm:openai";
import { renderToString } from "npm:react-dom/server";
const openai = new OpenAI();
return new Response(renderToString(jsx), { headers: { "Content-Type": "text/html" } });
const clientCode = () => {
document.getElementById("input").addEventListener("submit", function(event) {
</form>
<script dangerouslySetInnerHTML={{ __html: `(${clientCode.toString()})()` }}>
</script>
multirouteVue
@iamseeley
π Multi-Route Website with Vue
HTTP
* @title Multi-Route Website with Vue in Val Town
* @description Create a personal portfolio website with multiple pages using Vue 3 and server-side rendering.
import { createSSRApp, h } from 'npm:vue@3';
h('p', {}, [
h('strong', {}, 'This website is rendered server-side with Vue.')
h('p', {}, [
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>${personalData.name} | Server-side Vue</title>
<style>
MILLENCHAT
@LucasMillen
// "name": "AI Chat Assistant",
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";
class ErrorBoundary extends React.Component<
{ children: React.ReactNode },
constructor(props: { children: React.ReactNode }) {
componentDidCatch(error: Error, errorInfo: React.ErrorInfo) {
import React from "https://esm.sh/react@18.2.0";
import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
<React.StrictMode>
nighthawksChat
@yawnxyz
It's Late. Get a drink. Have a chat.
Welcome to Nighthawks. Nighthawks is an experiment in building interesting NPC characters with AI. The system combines large language models, simulates conversations using character sheets, and attempts to build memories based on the conversation. Improvise, have fun. Approach them like you would at a late night diner. Inspired by the Nighthawks painting. Built on a stripped down agent-based memory system.
HTTP
return nighthawks.characters[0];
return null;
// Server-side rendering
app.get("/", async (c) => {
const charId = c.req.query("char");
LetterMatch
@efoley
@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";
import confetti from "https://esm.sh/canvas-confetti@1.6.0";
</div>
function client() {
createRoot(document.getElementById("root")).render(<App />);
if (typeof document !== "undefined") { client(); }
export default async function server(request: Request): Promise<Response> {
altairClient
@flesch
Altair GraphQL Client import { altairClient } from "https://esm.town/v/flesch/altairClient";
import { graphql, GraphQLObjectType, GraphQLSchema, GraphQLString } from "https://esm.sh/graphql";
// Define the GraphQL schema
const schema = new GraphQLSchema({
query: new GraphQLObjectType({
name: "Query",
fields: {
hello: {
type: GraphQLString,
resolve: () => "Hello from Val Town GraphQL API!",
},
},
}),
});
// Function to handle GraphQL requests
async function handleGraphQLRequest(request: Request): Promise<Response> {
const { query, variables } = await request.json();
const result = await graphql({
schema,
source: query,
variableValues: variables,
});
return new Response(JSON.stringify(result), {
headers: {
"Content-Type": "application/json"
},
});
}
// HTTP handler function
export default altairClient(async function(req: Request): Promise<Response> {
if (req.method === "POST") {
return handleGraphQLRequest(req);
} else {
return new Response("This endpoint only accepts POST requests for GraphQL queries.", { status: 405 });
}
}); β https://www.val.town/v/flesch/graphqlAPIEndpoint
HTTP
# Altair GraphQL Client
<div align="center">
```ts
import { altairClient } from "https://esm.town/v/flesch/altairClient";
import { graphql, GraphQLObjectType, GraphQLSchema, GraphQLString } from "https://esm.sh/graphql";
// HTTP handler function
export default altairClient(async function(req: Request): Promise<Response> {
if (req.method === "POST") {
import { getDistDirectory, renderAltair, RenderOptions } from "npm:altair-static";
export function altairClient(next: (request: Request) => Response | Promise<Response>, options?: RenderOptions) {
return async (request: Request) => {
return next(request);
export default altairClient(async function(request: Request): Promise<Response> {
return new Response("Not found", { status: 404 });
bombCycloneOutageTracker
@andreterron
πͺοΈ Γ π Bomb Cyclone - PSE Power Outage Tracker https://bomb-cyclone.terron.app Tracking PSE power outages after the Bomb Cyclone of Nov 19th, 2024. The data is obtained every 15 minutes using this cron job: @andreterron/PSEoutages Tracking started on Nov 20th, at around 7pm PST. If you know how others can help those affected by the outage, please add a comment here. I'll keep updating this readme and the website with more information.
HTTP
/** @jsxImportSource https://esm.sh/react */
import { format } from "https://esm.sh/date-fns@4/format.mjs";
import React, { useEffect, useState } from "https://esm.sh/react@18";
import {
</div>
async function client() {
const ReactDOM = await import("https://esm.sh/react-dom@18");
console.log(ReactDOM);
const root = ReactDOM.createRoot(document.getElementById("root"));
root.render(<App />);
if (typeof document !== "undefined") { client(); }
export default async function server(request: Request): Promise<Response> {
allvals
@ejfox
An interactive, runnable TypeScript val by ejfox
HTTP
try {
debugMessages.push("Starting server-side processing");
const token = Deno.env.get('valtown');
debugMessages.push("Valtown token retrieved from environment");
const client = new ValTown({ apiKey: token });
debugMessages.push("ValTown client initialized");
const username = 'ejfox';
try {
user = await client.alias.username.retrieve(username);
debugMessages.push(`User data retrieved: ${JSON.stringify(user)}`);
try {
for await (const val of client.users.vals.list(user.id, { limit: 100 })) {
vals.push(val);