-
Notifications
You must be signed in to change notification settings - Fork 541
Add SolidStart example #2387
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
thomasbuilds
wants to merge
16
commits into
thirdweb-dev:develop
Choose a base branch
from
thomasbuilds:develop
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add SolidStart example #2387
Changes from 9 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
103b9b4
Add SolidStart web3 onboarding template
thomasbuilds dc27992
Update examples/with-solidstart/.env.example
thomasbuilds 84b91f8
Update examples/with-solidstart/src/entry-server.tsx
thomasbuilds 3b9d58d
Update examples/with-solidstart/src/auth/Provider.tsx
thomasbuilds d86a892
Update image class widths in about.tsx
thomasbuilds 7a49ba6
Refactor wallet connection logic in Provider.tsx
thomasbuilds 11444d2
Update examples/with-solidstart/src/auth/Provider.tsx
thomasbuilds 817e43d
Update SESSION_SECRET example in .env file
thomasbuilds 2bcd3fa
formatted code according to project + minor update
thomasbuilds 67b3682
update
thomasbuilds 6c66b5b
update
thomasbuilds b56067c
Update examples/with-solidstart/src/app.css
thomasbuilds 3f35175
Update examples/with-solidstart/src/auth/server.ts
thomasbuilds edda5be
Update README.md
thomasbuilds 5c9b122
Fix class attribute usage in Icons component
thomasbuilds eb3d5f5
Revise README for SolidStart example
thomasbuilds File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| # Generate using `openssl rand -hex 32` | ||
| SESSION_SECRET=your-32char-secret-key-goes-here |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| node_modules | ||
| .data | ||
| pnpm-lock.yaml | ||
| package-lock.json | ||
| .env |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| [](https://github.com/solidjs/solid-start) | ||
|
|
||
| Kickstart your DeFi app development with this starter template, built with [SolidStart](https://start.solidjs.com) and [Web3Onboard](https://web3onboard.thirdweb.com). | ||
| It seamlessly integrates SolidStart’s server-side rendering (_SSR_) with client-side Web3 features, leveraging libraries like [ethers.js](https://github.com/ethers-io/ethers.js). | ||
|
|
||
| ## Features | ||
|
|
||
| - **SSR Compliant**: Web3 code loads only on the client, ensuring compatibility with SSR architecture | ||
| - **Auth Context**: A reactive context to monitor wallet changes, handle signatures, and more | ||
| - **Local Storage**: Utilizes a lightweight, file-based database with `unstorage` for persistence | ||
| - **Starter Kit for DeFi**: Preconfigured setup to kickstart your DeFi app development with SolidStart and Web3Onboard | ||
| - **Client-Only**: Easily isolate client-side logic for Web3 interactions | ||
|
|
||
| ## Getting Started | ||
|
|
||
| 1. Install dependencies | ||
|
|
||
| ```bash | ||
| # use preferred package manager | ||
| npm install | ||
| ``` | ||
|
|
||
| 2. Run the development server | ||
|
|
||
| ```bash | ||
| # use preferred package manager | ||
| npm run dev | ||
| ``` | ||
|
|
||
| 3. Rename `.env.example` to `.env`. For production, generate a secure `SESSION_SECRET` with | ||
|
|
||
| ```bash | ||
| openssl rand -hex 32 | ||
| ``` | ||
|
|
||
| ## 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. **Client-Only Component** (e.g. for a component showing user balance) | ||
|
|
||
| ```jsx | ||
| import { clientOnly } from '@solidjs/start/client' | ||
|
|
||
| const ClientComponent = clientOnly(() => import('./ClientOnlyComponent')) | ||
| ``` | ||
|
|
||
| 2. **Client-Only Page** (e.g. for a `/swap` page) | ||
| Add the following at the top of your route file to render the entire page on the client: | ||
|
|
||
| ```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). | ||
|
|
||
| <div align="center"> | ||
| </br> | ||
| </br> | ||
| <img src="public/logo.svg" width="300px"> | ||
| </div> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| import { defineConfig } from '@solidjs/start/config' | ||
| import tailwindcss from '@tailwindcss/vite' | ||
|
|
||
| export default defineConfig({ | ||
| server: { preset: '' }, // your deployment | ||
| vite: { plugins: [tailwindcss()] } | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| { | ||
| "type": "module", | ||
| "scripts": { | ||
| "dev": "vinxi dev --port 3001", | ||
| "build": "vinxi build", | ||
| "start": "vinxi start" | ||
| }, | ||
| "dependencies": { | ||
| "@solidjs/meta": "^0.29.4", | ||
| "@solidjs/router": "^0.15.3", | ||
| "@solidjs/start": "^1.2.0", | ||
| "@web3-onboard/core": "^2.24.1", | ||
| "@web3-onboard/injected-wallets": "^2.11.3", | ||
| "ethers": "^6.15.0", | ||
| "solid-js": "^1.9.10", | ||
| "unstorage": "1.17.1", | ||
| "vinxi": "^0.5.8" | ||
| }, | ||
| "devDependencies": { | ||
| "@tailwindcss/vite": "^4.1.16", | ||
| "tailwindcss": "^4.1.16" | ||
| }, | ||
| "engines": { | ||
| "node": ">=22" | ||
| } | ||
| } |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| @import 'tailwindcss'; | ||
|
|
||
| #app { | ||
| background-color: white; | ||
| user-select: none; | ||
| @media (scripting: none) { | ||
| display: none; | ||
| } | ||
| } | ||
|
|
||
| main { | ||
| @apply flex flex-col items-center justify-center min-h-screen bg-gray-50 gap-18 px-4; | ||
| } | ||
|
|
||
| h1 { | ||
| @apply uppercase text-6xl text-sky-700 font-thin; | ||
| } | ||
|
|
||
| button { | ||
| cursor: pointer; | ||
| } | ||
|
|
||
| .loader { | ||
| @apply animate-spin border-current border-t-transparent text-current rounded-full; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| import { Suspense } from 'solid-js' | ||
| import { Router, type RouteDefinition } from '@solidjs/router' | ||
| import { FileRoutes } from '@solidjs/start/router' | ||
| import { MetaProvider } from '@solidjs/meta' | ||
| import { querySession } from './auth' | ||
| import AuthProvider from './auth/Provider' | ||
| import Nav from './components/Nav' | ||
| import ErrorNotification from './components/Error' | ||
| import './app.css' | ||
|
|
||
| export const route: RouteDefinition = { | ||
| preload: ({ location }) => querySession(location.pathname) | ||
| } | ||
|
|
||
| export default function App() { | ||
| return ( | ||
| <Router | ||
| root={props => ( | ||
| <MetaProvider> | ||
| <AuthProvider> | ||
| <Suspense> | ||
| <Nav /> | ||
| {props.children} | ||
| <ErrorNotification /> | ||
| </Suspense> | ||
| </AuthProvider> | ||
| </MetaProvider> | ||
| )} | ||
| > | ||
| <FileRoutes /> | ||
| </Router> | ||
| ) | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.