Skip to content

Commit bf60761

Browse files
committed
fix dotenv issue
1 parent 0991e92 commit bf60761

File tree

13 files changed

+1084
-22
lines changed

13 files changed

+1084
-22
lines changed

apps/example-dapp/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,5 @@ dist-ssr
2222
*.njsproj
2323
*.sln
2424
*.sw?
25+
26+
.tanstack/

apps/example-dapp/package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"@solana/wallet-adapter-wallets": "^0.19.37",
2020
"@tailwindcss/vite": "^4.1.11",
2121
"@tanstack/react-query": "^5.84.2",
22+
"@tanstack/react-router": "^1.131.2",
2223
"class-variance-authority": "^0.7.1",
2324
"clsx": "^2.1.1",
2425
"gill": "^0.10.3",
@@ -31,6 +32,9 @@
3132
},
3233
"devDependencies": {
3334
"@eslint/js": "^9.33.0",
35+
"@tanstack/react-query-devtools": "^5.84.2",
36+
"@tanstack/react-router-devtools": "^1.131.2",
37+
"@tanstack/router-plugin": "^1.131.2",
3438
"@types/react": "^19.1.9",
3539
"@types/react-dom": "^19.1.7",
3640
"@vitejs/plugin-react": "^4.7.0",

apps/example-dapp/src/App.tsx

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,35 @@ import {
1010
SolflareWalletAdapter,
1111
} from "@solana/wallet-adapter-wallets";
1212
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
13+
import { ReactQueryDevtools } from "@tanstack/react-query-devtools";
14+
import { createRouter, RouterProvider } from "@tanstack/react-router";
1315
import { SolanaProvider } from "gill-react";
1416
import { useMemo } from "react";
1517
import { Toaster } from "sonner";
1618

17-
import { SimpleDashboard } from "./components/SimpleDashboard";
1819
import { ThemeProvider } from "./components/theme-provider";
20+
import { routeTree } from "./routeTree.gen";
21+
22+
// Create the router instance
23+
const router = createRouter({ routeTree });
24+
25+
// Register the router instance for maximum type safety
26+
declare module "@tanstack/react-router" {
27+
interface Register {
28+
router: typeof router;
29+
}
30+
}
1931

2032
import "@solana/wallet-adapter-react-ui/styles.css";
2133
import { createSolanaClient } from "gill";
2234

35+
console.log(import.meta.env);
36+
console.log(import.meta.env.VITE_SOLANA_RPC_URL ?? "mainnet-beta");
37+
2338
const queryClient = new QueryClient();
24-
const solanaClient = createSolanaClient({ urlOrMoniker: "mainnet-beta" });
39+
const solanaClient = createSolanaClient({
40+
urlOrMoniker: import.meta.env.VITE_SOLANA_RPC_URL ?? "mainnet-beta",
41+
});
2542

2643
function App() {
2744
const wallets = useMemo(
@@ -39,8 +56,9 @@ function App() {
3956
<SolanaProvider client={solanaClient}>
4057
<GrillProvider>
4158
<div className="min-h-screen bg-background">
42-
<SimpleDashboard />
59+
<RouterProvider router={router} />
4360
<Toaster position="bottom-right" />
61+
<ReactQueryDevtools initialIsOpen={false} />
4462
</div>
4563
</GrillProvider>
4664
</SolanaProvider>

apps/example-dapp/src/main.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { StrictMode } from 'react'
2-
import { createRoot } from 'react-dom/client'
3-
import './index.css'
4-
import App from './App.tsx'
1+
import { StrictMode } from "react";
2+
import { createRoot } from "react-dom/client";
3+
import "./index.css";
4+
import App from "./App.tsx";
55

6-
createRoot(document.getElementById('root')!).render(
6+
createRoot(document.getElementById("root")!).render(
77
<StrictMode>
88
<App />
9-
</StrictMode>,
10-
)
9+
</StrictMode>
10+
);
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/* eslint-disable */
2+
3+
// @ts-nocheck
4+
5+
// noinspection JSUnusedGlobalSymbols
6+
7+
// This file was automatically generated by TanStack Router.
8+
// You should NOT make any changes in this file as it will be overwritten.
9+
// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified.
10+
11+
import { Route as rootRouteImport } from './routes/__root'
12+
import { Route as DashboardRouteImport } from './routes/dashboard'
13+
import { Route as IndexRouteImport } from './routes/index'
14+
15+
const DashboardRoute = DashboardRouteImport.update({
16+
id: '/dashboard',
17+
path: '/dashboard',
18+
getParentRoute: () => rootRouteImport,
19+
} as any)
20+
const IndexRoute = IndexRouteImport.update({
21+
id: '/',
22+
path: '/',
23+
getParentRoute: () => rootRouteImport,
24+
} as any)
25+
26+
export interface FileRoutesByFullPath {
27+
'/': typeof IndexRoute
28+
'/dashboard': typeof DashboardRoute
29+
}
30+
export interface FileRoutesByTo {
31+
'/': typeof IndexRoute
32+
'/dashboard': typeof DashboardRoute
33+
}
34+
export interface FileRoutesById {
35+
__root__: typeof rootRouteImport
36+
'/': typeof IndexRoute
37+
'/dashboard': typeof DashboardRoute
38+
}
39+
export interface FileRouteTypes {
40+
fileRoutesByFullPath: FileRoutesByFullPath
41+
fullPaths: '/' | '/dashboard'
42+
fileRoutesByTo: FileRoutesByTo
43+
to: '/' | '/dashboard'
44+
id: '__root__' | '/' | '/dashboard'
45+
fileRoutesById: FileRoutesById
46+
}
47+
export interface RootRouteChildren {
48+
IndexRoute: typeof IndexRoute
49+
DashboardRoute: typeof DashboardRoute
50+
}
51+
52+
declare module '@tanstack/react-router' {
53+
interface FileRoutesByPath {
54+
'/dashboard': {
55+
id: '/dashboard'
56+
path: '/dashboard'
57+
fullPath: '/dashboard'
58+
preLoaderRoute: typeof DashboardRouteImport
59+
parentRoute: typeof rootRouteImport
60+
}
61+
'/': {
62+
id: '/'
63+
path: '/'
64+
fullPath: '/'
65+
preLoaderRoute: typeof IndexRouteImport
66+
parentRoute: typeof rootRouteImport
67+
}
68+
}
69+
}
70+
71+
const rootRouteChildren: RootRouteChildren = {
72+
IndexRoute: IndexRoute,
73+
DashboardRoute: DashboardRoute,
74+
}
75+
export const routeTree = rootRouteImport
76+
._addFileChildren(rootRouteChildren)
77+
._addFileTypes<FileRouteTypes>()
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { createRootRoute, Link, Outlet } from "@tanstack/react-router";
2+
import { TanStackRouterDevtools } from "@tanstack/react-router-devtools";
3+
import { Button } from "@/components/ui/button";
4+
5+
export const Route = createRootRoute({
6+
component: () => (
7+
<>
8+
<nav className="flex gap-4 p-4 border-b">
9+
<Link to="/">
10+
{({ isActive }) => (
11+
<Button variant={isActive ? "default" : "ghost"}>Simple Dashboard</Button>
12+
)}
13+
</Link>
14+
<Link to="/dashboard">
15+
{({ isActive }) => (
16+
<Button variant={isActive ? "default" : "ghost"}>Dashboard</Button>
17+
)}
18+
</Link>
19+
</nav>
20+
<Outlet />
21+
<TanStackRouterDevtools position="bottom-left" />
22+
</>
23+
),
24+
});
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { createFileRoute } from "@tanstack/react-router";
2+
import { SimpleDashboard } from "@/components/SimpleDashboard";
3+
4+
export const Route = createFileRoute("/dashboard")({
5+
component: SimpleDashboard,
6+
});
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { createFileRoute } from "@tanstack/react-router";
2+
import { SimpleDashboard } from "@/components/SimpleDashboard";
3+
4+
export const Route = createFileRoute("/")({
5+
component: SimpleDashboard,
6+
});
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
11
/// <reference types="vite/client" />
2+
3+
interface ImportMetaEnv {
4+
readonly VITE_SOLANA_RPC_URL?: string;
5+
}

apps/example-dapp/vite.config.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,21 @@
11
import path from "node:path";
22
import tailwindcss from "@tailwindcss/vite";
3+
import { tanstackRouter } from "@tanstack/router-plugin/vite";
34
import react from "@vitejs/plugin-react";
45
import { defineConfig } from "vite";
56
import { nodePolyfills } from "vite-plugin-node-polyfills";
67

78
// https://vite.dev/config/
89
export default defineConfig({
9-
plugins: [react(), tailwindcss(), nodePolyfills()],
10+
plugins: [
11+
tanstackRouter({
12+
target: "react",
13+
autoCodeSplitting: true,
14+
}),
15+
react(),
16+
tailwindcss(),
17+
nodePolyfills(),
18+
],
1019
resolve: {
1120
alias: {
1221
"@": path.resolve(__dirname, "./src"),

0 commit comments

Comments
 (0)