Skip to content

Commit

Permalink
add use server references to solid-ssr example
Browse files Browse the repository at this point in the history
  • Loading branch information
nksaraf committed Aug 9, 2023
1 parent 31777cf commit c7bc296
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 1 deletion.
10 changes: 9 additions & 1 deletion examples/solid/ssr/basic/app.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
import { references } from "@vinxi/plugin-references";
import { createApp } from "vinxi";
import solid from "vite-plugin-solid";

export default createApp({
server: {
plugins: [references.serverPlugin],
virtual: {
[references.serverPlugin]: references.serverPluginModule,
},
},
routers: [
{
name: "public",
Expand All @@ -15,7 +22,7 @@ export default createApp({
handler: "./app/client.tsx",
build: {
target: "browser",
plugins: () => [solid({ ssr: true })],
plugins: () => [references.clientRouterPlugin(), solid({ ssr: true })],
},
base: "/_build",
},
Expand All @@ -28,5 +35,6 @@ export default createApp({
plugins: () => [solid({ ssr: true })],
},
},
references.serverRouter(),
],
});
12 changes: 12 additions & 0 deletions examples/solid/ssr/basic/app/actions.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
"use server";

let store = { count: 0 };
export function sayHello() {
console.log("Hello World");
store.count++;
return store.count;
}

export function getStore() {
return store.count;
}
3 changes: 3 additions & 0 deletions examples/solid/ssr/basic/app/client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ import { createAssets } from "@vinxi/solid";
import { NoHydration, Suspense, hydrate } from "solid-js/web";
import "vinxi/runtime/client";

import { sayHello } from "./actions";
import App from "./app";

console.log(await sayHello());

const Assets = createAssets(
import.meta.env.MANIFEST["client"].handler,
import.meta.env.MANIFEST["client"],
Expand Down
1 change: 1 addition & 0 deletions examples/solid/ssr/basic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"dependencies": {
"@picocss/pico": "^1.5.7",
"@solidjs/meta": "^0.28.5",
"@vinxi/plugin-references": "workspace:^",
"@vinxi/solid": "workspace:^",
"autoprefixer": "^10.4.14",
"solid-js": "^1.7.8",
Expand Down
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c7bc296

Please sign in to comment.