|
1 | | -import { join } from 'path'; |
2 | | -import { createEffect, createSignal } from "solid-js"; |
3 | | -import { isServer } from "solid-js/web"; |
4 | | - |
| 1 | +import { MetaProvider, Title } from "@solidjs/meta"; |
| 2 | +import { Router } from "@solidjs/router"; |
| 3 | +import { FileRoutes } from "@solidjs/start/router"; |
| 4 | +import { Suspense } from "solid-js"; |
5 | 5 | import "./app.css"; |
6 | 6 |
|
7 | | -function serverFnWithIsServer() { |
8 | | - "use server"; |
9 | | - |
10 | | - return isServer; |
11 | | -} |
12 | | - |
13 | | -function serverFnWithNodeBuiltin() { |
14 | | - "use server"; |
15 | | - |
16 | | - return join('can','externalize'); |
17 | | -} |
18 | | - |
19 | 7 | export default function App() { |
20 | | - const [output, setOutput] = createSignal<{ clientWithIsServer?: boolean; serverFnWithIsServer?: boolean, serverFnWithNodeBuiltin?: string }>({}); |
21 | | - |
22 | | - setOutput(prev => ({ ...prev, clientWithIsServer: isServer })); |
23 | | - |
24 | | - createEffect(async () => { |
25 | | - const restult = await serverFnWithIsServer(); |
26 | | - setOutput(prev => ({ ...prev, serverFnWithIsServer: restult })); |
27 | | - }); |
28 | | - |
29 | | - createEffect(async () => { |
30 | | - const restult = await serverFnWithNodeBuiltin(); |
31 | | - setOutput(prev => ({ ...prev, serverFnWithNodeBuiltin: restult })); |
32 | | - }); |
33 | | - |
34 | 8 | return ( |
35 | | - <main> |
36 | | - <h1>Hello world!</h1> |
37 | | - <span id="server-fn-test">{JSON.stringify(output())}</span> |
38 | | - </main> |
| 9 | + <Router |
| 10 | + root={props => ( |
| 11 | + <MetaProvider> |
| 12 | + <Title>SolidStart - Basic</Title> |
| 13 | + <a href="/">Client</a> |
| 14 | + <a href="/is-server">isserver</a> |
| 15 | + <a href="/node-builtin">node builtin</a> |
| 16 | + <a href="/npm-module">npm module (lodash)</a> |
| 17 | + <Suspense>{props.children}</Suspense> |
| 18 | + </MetaProvider> |
| 19 | + )} |
| 20 | + > |
| 21 | + <FileRoutes /> |
| 22 | + </Router> |
39 | 23 | ); |
40 | 24 | } |
0 commit comments