199- **Storage Strategy:** Only use backend storage if explicitly required; prefer simple static client-side sites
200- For persistence, use Val Town SQLite or Blob storage with `import.meta.url` for keys/table names
201- **React Configuration:** When using React libraries, pin versions with `?deps=react@18.2.0,react-dom@18.2.0` and include the `@jsxImportSource` pragma
202- When facing client-side render issues, check if all React dependencies are pinned to the same version
203- **Styling:** Default to using TailwindCSS via `<script src="https://cdn.twind.style" crossorigin></script>` unless otherwise specified
204
262
263### Frontend Best Practices
264- Structure as a standard client-side React app
265- Use SVG for favicons (Val Town only supports text files)
266- Separate components into individual files
267- Access bootstrapped data from `window.__INITIAL_DATA__`
268- Use React 18.2.0 consistently in all imports and the `@jsxImportSource` pragma
269- Follow the React component pattern from the example project
270- Handle API calls properly with proper error catching
271
289 - Always run table creation before querying
290
2913. **React Configuration:**
292 - All React dependencies must be pinned to 18.2.0
293 - Always include `@jsxImportSource https://esm.sh/react@18.2.0` at the top of React files
294 - Rendering issues often come from mismatched React versions
295
2964. **File Handling:**
1/** @jsxImportSource https://esm.sh/react@18.2.0 */
2import React, {
3 useState,
4 useEffect,
5 useCallback,
6 useMemo,
7} from "https://esm.sh/react@18.2.0";
8import { type Memory } from "../../shared/types.ts";
9import { ASSETS, SCENE_POSITIONS, SOURCE_TYPES } from "./assets.ts";
165 }, [fetchMemories]);
166
167 const handleAddMemory = async (e: React.FormEvent) => {
168 e.preventDefault();
169 if (!newMemoryText.trim()) return;
220 };
221
222 const handleUpdateMemory = async (e: React.FormEvent) => {
223 e.preventDefault();
224 if (!editingMemory || !editingMemory.text.trim()) return;
1/** @jsxImportSource https://esm.sh/react@18.2.0 */
2import { ValTown } from "https://esm.sh/@valtown/sdk";
3import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
4import React, { useRef, useState, useEffect } from "https://esm.sh/react@18.2.0";
5
6function App() {
11
12- **Responsive Layout: 📱🖥️**
13 - Built with a beautiful and modern UI using React and TailwindCSS, ensuring a pleasant experience across devices.
14
15- **Live Preview and Copy: 📋**
38## Technologies Used
39
40- **React:** For building the interactive user interface.
41- **React DOM:** To render components efficiently.
42- **TailwindCSS:** For styling the application.
43- **Deno:** The server-side environment.
1/** @jsxImportSource https://esm.sh/react@18.2.0 */
2import { type Context, Hono } from "https://esm.sh/hono";
3import { debounce } from "https://esm.sh/lodash-es";
4import React, { ReactNode, useCallback, useEffect, useRef, useState } from "https://esm.sh/react@18.2.0";
5import { parseProject } from "https://esm.town/v/std/parseImportMeta/project";
6import { lastlogin } from "https://esm.town/v/stevekrouse/lastlogin_safe";
1/** @jsxImportSource https://esm.sh/react@18.2.0 */
2import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
3import { useDropzone } from "https://esm.sh/react-dropzone?deps=react@18.2.0,react-dom@18.2.0";
4import React, { ReactNode, useCallback, useEffect, useRef, useState } from "https://esm.sh/react@18.2.0";
5import { LoginWithGoogleButton } from "https://esm.town/v/stevekrouse/LoginWithGoogleButton";
6
7interface TooltipProps {
8 children: ReactNode;
9 content: string;
10}
4
5app.get("/", async (c) => {
6 // create a single page react app that is deployed at this endpoint
7 const valTownURL = import.meta.url;
8 const notionURL = "https://www.notion.so/bradnoble/val-town-for-Notion-1cbc200736c2807bb445eccf64d0afe9";
4
5app.get("/", async (c) => {
6 // create a single page react app that is deployed at this endpoint
7 const valTownURL = import.meta.url;
8 const notionURL = "https://www.notion.so/bradnoble/val-town-for-Notion-1cbc200736c2807bb445eccf64d0afe9";
1/**
2 * @jsxImportSource https://esm.sh/react@18.2.0
3 */
4
1# React Hono Val Town Project Starter Template
2
3This is a starter template for a full-stack app in a Val Town Project. The app itself is a simple persistent message board.