├── .gitignore ├── .vscode └── settings.json ├── src ├── trpc │ ├── trpc.ts │ └── client.ts ├── react-query │ ├── query-client.ts │ └── useDehydrateReactQuery.tsx ├── twind │ ├── twind.ts │ └── TwindProvider.tsx ├── server │ └── router.ts └── app.tsx ├── README.md ├── deno.json ├── client.tsx ├── importMap.json ├── LICENSE ├── server.tsx └── public └── favicon.ico /.gitignore: -------------------------------------------------------------------------------- 1 | .ultra 2 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "deno.enable": true, 3 | "editor.defaultFormatter": "denoland.vscode-deno" 4 | } 5 | -------------------------------------------------------------------------------- /src/trpc/trpc.ts: -------------------------------------------------------------------------------- 1 | import { createTRPCReact } from "@trpc/react"; 2 | import { AppRouter } from "../server/router.ts"; 3 | 4 | export const trpc = createTRPCReact(); 5 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # [tRPC](https://trpc.io) + [Ultra](https://ultrajs.dev) 2 | 3 | ```sh 4 | git clone https://github.com/sachinraja/trpc-ultra 5 | cd trpc-ultra 6 | deno task dev 7 | ``` 8 | -------------------------------------------------------------------------------- /src/react-query/query-client.ts: -------------------------------------------------------------------------------- 1 | import { QueryClient } from "@tanstack/react-query"; 2 | 3 | export const queryClient = new QueryClient({ 4 | defaultOptions: { 5 | queries: { 6 | suspense: true, 7 | }, 8 | }, 9 | }); 10 | -------------------------------------------------------------------------------- /deno.json: -------------------------------------------------------------------------------- 1 | { 2 | "tasks": { 3 | "dev": "deno run -A --no-check --watch ./server.tsx", 4 | "test": "deno test --allow-all", 5 | "build": "deno run -A ./build.ts", 6 | "start": "ULTRA_MODE=production deno run -A --no-remote ./server.js" 7 | }, 8 | "compilerOptions": { 9 | "jsx": "react-jsxdev", 10 | "jsxImportSource": "react", 11 | "lib": [ 12 | "deno.window", 13 | "DOM" 14 | ] 15 | }, 16 | "importMap": "./importMap.json" 17 | } 18 | -------------------------------------------------------------------------------- /src/trpc/client.ts: -------------------------------------------------------------------------------- 1 | import { httpBatchLink } from "@trpc/client"; 2 | import { trpc } from "../trpc/trpc.ts"; 3 | 4 | const getBaseUrl = () => { 5 | if (typeof Deno === "undefined") { 6 | // In the browser, we return a relative URL 7 | return ""; 8 | } 9 | 10 | // When rendering on the server, we return an absolute URL 11 | // assume localhost 12 | return "http://localhost:8000"; 13 | }; 14 | 15 | export const trpcClient = trpc.createClient({ 16 | links: [ 17 | httpBatchLink({ 18 | url: `${getBaseUrl()}/api/trpc`, 19 | }), 20 | ], 21 | }); 22 | -------------------------------------------------------------------------------- /src/twind/twind.ts: -------------------------------------------------------------------------------- 1 | import { cssomSheet, setup } from "twind"; 2 | import { virtualSheet } from "twind/sheets"; 3 | 4 | /** 5 | * Depending on if we are running server side (Deno) or on the browser 6 | * we construct a VirtualSheet OR a CSSStyleSheet which will be populated 7 | * with the injected CSSStyleSheet from the injected style tag below. 8 | */ 9 | 10 | export const sheet = typeof Deno !== "undefined" ? virtualSheet() : cssomSheet({ 11 | target: (document.getElementById("__twind") as HTMLStyleElement).sheet || 12 | undefined, 13 | }); 14 | 15 | /** 16 | * Your theme configuration for twind 17 | */ 18 | const theme = {}; 19 | 20 | setup({ sheet, theme }); 21 | -------------------------------------------------------------------------------- /src/server/router.ts: -------------------------------------------------------------------------------- 1 | import { initTRPC } from "@trpc/server"; 2 | import { z } from "zod"; 3 | 4 | const posts = [ 5 | { name: "First Post" }, 6 | { name: "Second Post" }, 7 | { name: "Third Post" }, 8 | ]; 9 | 10 | const t = initTRPC.create(); 11 | 12 | const postRouter = t.router({ 13 | get: t.procedure.query(() => posts), 14 | create: t.procedure 15 | .input(z.object({ name: z.string() })) 16 | .mutation(({ input }) => { 17 | posts.push(input); 18 | return input; 19 | }), 20 | }); 21 | 22 | export const appRouter = t.router({ 23 | hello: t.procedure.query(() => "world"), 24 | post: postRouter, 25 | }); 26 | 27 | export type AppRouter = typeof appRouter; 28 | -------------------------------------------------------------------------------- /src/react-query/useDehydrateReactQuery.tsx: -------------------------------------------------------------------------------- 1 | import { dehydrate, QueryClient } from "@tanstack/react-query"; 2 | import useServerInsertedHTML from "ultra/hooks/use-server-inserted-html.js"; 3 | 4 | export function useDehydrateReactQuery(queryClient: QueryClient) { 5 | useServerInsertedHTML(() => { 6 | /** 7 | * Dehydrate the state from queryClient 8 | */ 9 | const dehydratedState = dehydrate(queryClient); 10 | 11 | return ( 12 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | ultra/favicon.ico at main · exhibitionist-digital/ultra · GitHub 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 |
170 | Skip to content 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 765 | 766 |
767 | 768 |
769 | 770 | 771 | 772 | 773 | 774 | 775 | 776 |
777 | 778 | 779 | 780 | 781 | 796 |
797 | 798 | 799 | 800 | 801 | 802 | 803 | 804 | 805 | 806 | 807 |
813 |
814 |
815 | 816 | 817 | 818 | 819 | 820 | 821 | 822 | 823 | 824 | 825 | 826 | 827 | 828 |
829 | 830 |
831 | 832 |
833 | 834 |
835 | 838 | 839 | 842 | / 843 | 844 | ultra 845 | 846 | 847 | Public 848 |
849 | 850 | 851 |
852 | 853 | 891 | 892 |
893 | 894 |
895 |
896 | 897 | 898 | 1029 | 1030 | 1031 | 1032 |
1033 | 1034 | 1035 | 1036 | 1037 |
1038 | 1039 | 1040 | 1041 | 1042 | 1043 | 1044 |
1045 | 1046 | 1047 |
1048 | 1049 | 1050 | 1051 | 1052 | 1053 | 1054 | 1055 | 1056 | Permalink 1057 | 1058 |
1059 | 1060 |
1061 |
1065 | 1068 | 1071 | main 1072 | 1073 | 1074 | 1075 | 1076 |
1077 |
1078 |
1079 | Switch branches/tags 1080 | 1083 |
1084 | 1085 | 1086 | 1087 |
1088 | 1099 |
1100 | 1101 |
1102 | 1103 | 1104 |
1105 | 1106 |
1107 | 1123 | 1124 | 1127 | 1128 | 1131 | 1132 | 1133 | 1141 | 1142 | 1151 | 1152 | 1153 | 1154 | 1155 | 1156 |
1157 | 1158 | 1204 |
1205 |
1206 |
1207 |
1208 | 1209 |
1210 | 1211 |
1212 | 1213 | 1216 | Go to file 1217 | 1218 |
1219 | 1220 | 1221 | 1222 | 1223 |
1251 |
1252 |
1253 | 1254 | 1255 | 1256 | 1257 | 1258 | 1271 | 1272 | 1273 | 1274 |
1275 | 1276 |
1277 |
1278 |
 
1279 |
1280 | 1281 |
1282 |
 
1283 | Cannot retrieve contributors at this time 1284 |
1285 |
1286 | 1287 | 1288 | 1289 | 1290 | 1291 | 1292 | 1293 | 1294 | 1295 |
1296 | 1297 |
1301 | 1302 | 1303 |
1304 | 1305 | 14.7 KB 1306 |
1307 | 1308 |
1309 | 1310 | 1311 | 1314 | 1315 |
1316 |
1317 | 1323 |
1324 |
1325 | 1326 |
1327 | 1359 |
1360 |
1361 | 1362 | 1363 | 1364 |
1365 | 1366 |
1367 | View raw 1368 |
1369 |
1370 | 1371 |
1372 | 1373 | 1374 | 1375 | 1376 |
1377 | 1378 | 1379 |
1380 | 1381 | 1383 |
1384 |
1385 | 1386 | 1387 | 1388 |
1389 | 1390 |
1391 | 1392 | 1393 |
1394 | 1395 |
1396 | 1397 | 1398 |
1399 |
1400 | 1401 |
1402 | 1403 | 1441 | 1442 | 1443 | 1444 | 1445 | 1456 | 1457 | 1465 | 1478 | 1479 | 1483 | 1484 | 1496 | 1497 | 1498 | 1499 | 1500 | 1501 | 1502 | 1503 | --------------------------------------------------------------------------------