diff --git a/examples/with-solidstart/.env.example b/examples/with-solidstart/.env.example new file mode 100644 index 000000000..de0f9caca --- /dev/null +++ b/examples/with-solidstart/.env.example @@ -0,0 +1,2 @@ +# Generate using `openssl rand -hex 32` +SESSION_SECRET=your-32char-secret-key-goes-here diff --git a/examples/with-solidstart/.gitignore b/examples/with-solidstart/.gitignore new file mode 100644 index 000000000..d9ec65bf5 --- /dev/null +++ b/examples/with-solidstart/.gitignore @@ -0,0 +1,5 @@ +node_modules +.data +pnpm-lock.yaml +package-lock.json +.env diff --git a/examples/with-solidstart/README.md b/examples/with-solidstart/README.md new file mode 100644 index 000000000..da432325e --- /dev/null +++ b/examples/with-solidstart/README.md @@ -0,0 +1,63 @@ +[](https://web3onboard.thirdweb.com) + +# SolidStart Example + +Everything you need to integrate Web3Onboard in [SolidStart](https://start.solidjs.com) + +## Features + +- **SSR Compliant**: Web3 code loads only on the client +- **Auth Context**: A reactive context to monitor wallet changes, handle signatures, and more +- **Database**: Includes `unstorage`, a lightweight file-based DB +- **Client-Only**: Easily isolate client-side logic for Web3 interactions + +## Getting Started + +1. Rename `.env.example` to `.env`. For production, generate a secure `SESSION_SECRET` with + + ```bash + openssl rand -hex 32 + ``` + +2. Install dependencies + + ```bash + # use preferred package manager + npm install + ``` + +3. Run the development server + + ```bash + # use preferred package manager + npm run dev + ``` + +For more details, refer to SolidStart's [README.md](https://github.com/solidjs/solid-start/blob/main/packages/start/README.md) + +## Usage + +To ensure Web3-related logic runs only on the client, use the `clientOnly` utility from SolidStart. +Here are two ways to implement client-only code: + +1. **In Component** (e.g. for a component showing eth balance) + + ```jsx + import { clientOnly } from "@solidjs/start/client"; + + const ClientComponent = clientOnly(() => import("./ClientOnlyComponent")); + ``` + +2. **In Routes** (e.g. for a `/swap` page) + + ```jsx + import { clientOnly } from "@solidjs/start/client"; + + export default clientOnly(async () => ({ default: MyPage })); + ``` + +For more details, refer to the `clientOnly` [documentation](https://docs.solidjs.com/solid-start/reference/client/client-only#clientonly). + +
+Sorry, the page you’re looking for doesn't exist
+ + Go Home + + > + ); +} diff --git a/examples/with-solidstart/src/routes/about.tsx b/examples/with-solidstart/src/routes/about.tsx new file mode 100644 index 000000000..19ff853b5 --- /dev/null +++ b/examples/with-solidstart/src/routes/about.tsx @@ -0,0 +1,19 @@ +import { Title } from "@solidjs/meta"; + +export default function About() { + return ( + <> +