bun --bun run dev
import { MetaProvider, Title } from "@solidjs/meta";import { Router } from "@solidjs/router";import { FileRoutes } from "@solidjs/start/router";import { Suspense } from "solid-js";import "./app.css";export default function App() { return ( <Router root={props => ( <MetaProvider> <Title>SolidStart - Basic</Title> <a href="/">Index</a> <a href="/about">About</a> <Suspense>{props.children}</Suspense> </MetaProvider> )} > <FileRoutes /> </Router> );}
import { MetaProvider, Title } from "@solidjs/meta";import { Router } from "@solidjs/router";import { FileRoutes } from "@solidjs/start/router";import { Suspense } from "solid-js";import "./app.css";import { TestFetch } from "./components/TestFetch";export default function App() { return <TestFetch />;}
<Match when={user.latest}> <div>{JSON.stringify(user.latest)}</div> </Match>
import { createSignal, createResource, Switch, Match, Show, Suspense, startTransition, createEffect,} from "solid-js";const fetchUser = async (id: any) => { await new Promise((resolve) => setTimeout(resolve, 2000)); const response = await fetch(`https://swapi.dev/api/people/${id}/`); return response.json();};export function TestFetch() { const [userId, setUserId] = createSignal(); const [user] = createResource(userId, fetchUser, { initialValue: 1, }); return ( <div> <input type="number" min="1" placeholder="Enter Numeric Id" onInput={(e) => setUserId(e.currentTarget.value)} /> <Show when={user.loading}> <p>I'm LOADING!...</p> </Show> <Switch> <Match when={user.error}> <span>Error: {user.error}</span> </Match> <Match when={user()}> <div>{JSON.stringify(user())}</div> </Match> </Switch> </div> );}