1null
2
3Migrated from folder: Archive/dateme_react_router_rewrite/dateme_faq_react
1/** @jsxImportSource https://esm.sh/react */
2import { renderToString } from "https://esm.sh/react-dom@18.2.0/server";
3import { useEffect, useState } from "https://esm.sh/react@18.2.0";
4import { extractValInfo } from "https://esm.town/v/pomdtr/extractValInfo";
5import { html } from "https://esm.town/v/stevekrouse/html";
6
7// button that's disabled until client react hydrates
8export const Button = (props) => {
9 const [clientHydrated, setClientHydrated] = useState(false);
51 const props = await loader(req);
52 const script = `
53 import { hydrateRoot } from "https://esm.sh/react-dom@18.2.0/client";
54 import { jsx as _jsx } from "https://esm.sh/react@18.2.0/jsx-runtime";
55 import { Component } from "https://esm.town/v/${author}/${name}";
56
1# Starter App for [ssr_react_mini](https://www.val.town/v/stevekrouse/ssr_react_mini)
2
3You need to export four things:
4
51. `loader` - runs on any GET request, on the server. it accepts the `Request` and returns the props of your React compnent.
62. `action`- runs on the server on any non-GET, ie POST, PUT, DELETE, or `<form>`s submit
73. `Component` - your React component. it's initially server-rendered and then client-hydrated
84. `default` - you should mostly leave this line alone
9
10This is framework is bleeding-edge. You'll need to read the [code of the framework itself](https://www.val.town/v/stevekrouse/ssr_react_mini) (it's very short) to understand what it's doing.
11
12If you have questions or comments, please comment below on this val! (or any of these vals)
13
14Migrated from folder: Archive/ssr_react_mini_starter
5The router map url paths to component vals.
6
7Component vals must export a React Component as their default export:
8
9```ts
1import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
2import { jsx as _jsx } from "https://esm.sh/react/jsx-runtime";
3import { TodoApp } from "https://esm.town/v/stevekrouse/TodoApp";
4
1# Server-side Render React Mini Framework
2
3This is very experimental, more of a prototype of an architecture, than a true framework
5Example: https://www.val.town/v/stevekrouse/TodoApp
6
7Migrated from folder: Archive/ssr_react_mini
10import { sqlite } from "https://esm.town/v/std/sqlite?v=4";
11import { Hono } from "npm:hono";
12import { JSX } from "npm:react";
13
14export async function emailSubscription(req: Request) {
1/** @jsxImportSource https://esm.sh/preact */
2import { sqlite } from "https://esm.town/v/std/sqlite?v=4";
3
1/** @jsxImportSource https://esm.sh/preact */
2import { email } from "https://esm.town/v/std/email?v=11";
3import { sqlite } from "https://esm.town/v/std/sqlite?v=4";
4import { render } from "npm:preact-render-to-string";
5
6type SubscriberRow = [
1/** @jsxImportSource https://esm.sh/react */
2import { generateLessonHtml } from "https://esm.town/v/petermillspaugh/lessonTemplate";
3import { renderToString } from "npm:react-dom/server";
4
5/*
Starter template with client-side React & Hono server
Starter template with client-side React & Hono server
Write business logic with ease
Meet the new standard for modern TypeScript development.
Type-safe, reactive, framework-agnostic library to manage your business logic.
Follow me if you learn more about JavaScript | TypeScript | React.js | Next.js | Linux | NixOS | Frontend Developer | https://linktr.ee/officialrajdeepsingh