Last active
June 26, 2026 15:24
-
-
Save up1/a919462d24f3a9ae82cf365fcd40044d to your computer and use it in GitHub Desktop.
Deno Desktop
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
| $deno upgrade | |
| $deno --version | |
| deno 2.9.0 (stable, release, aarch64-apple-darwin) | |
| v8 14.9.207.2-rusty | |
| typescript 6.0.3 |
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
| $deno desktop main.ts | |
| ⚠ deno desktop is experimental and subject to change | |
| Compile main.ts to demo-desktop.dylib | |
| Embedded Files | |
| demo-desktop.dylib | |
| └── main.ts (3.53KB) | |
| Files: 5.03KB | |
| Metadata: 1.39KB | |
| Remote modules: 12B | |
| Codesigning bundle with identity "-" | |
| demo-desktop.app/Contents/MacOS/demo-desktop.dylib: replacing existing signature | |
| demo-desktop.app/Contents/MacOS/laufey_webview: replacing existing signature | |
| Bundle demo-desktop.app |
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
| const html = `<!doctype html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8" /> | |
| <title>Hello Deno Desktop</title> | |
| <style> | |
| body { | |
| margin: 0; | |
| height: 100vh; | |
| display: grid; | |
| place-items: center; | |
| font-family: system-ui, sans-serif; | |
| background: #111827; | |
| color: white; | |
| } | |
| main { | |
| text-align: center; | |
| } | |
| h1 { | |
| font-size: 3rem; | |
| margin-bottom: 0.5rem; | |
| } | |
| p { | |
| color: #d1d5db; | |
| font-size: 1.1rem; | |
| } | |
| button { | |
| margin-top: 1rem; | |
| padding: 0.75rem 1rem; | |
| border: 0; | |
| border-radius: 0.5rem; | |
| cursor: pointer; | |
| font-size: 1rem; | |
| } | |
| </style> | |
| </head> | |
| <body> | |
| <main> | |
| <h1>Hello from Deno Desktop 2026/06/24</h1> | |
| <p>Your web app is now running inside a desktop window</p> | |
| <button id="ping">Get data from REST API</button> | |
| <p id="result"></p> | |
| </main> | |
| <script> | |
| const button = document.getElementById("ping"); | |
| const result = document.getElementById("result"); | |
| button.addEventListener("click", async () => { | |
| const response = await fetch("/api/hello"); | |
| const data = await response.json(); | |
| result.textContent = data.message; | |
| }); | |
| </script> | |
| </body> | |
| </html>`; | |
| Deno.serve((request) => { | |
| const url = new URL(request.url); | |
| if (url.pathname === "/api/hello") { | |
| return Response.json({ | |
| message: "Hello from the Deno backend!", | |
| }); | |
| } | |
| return new Response(html, { | |
| headers: { | |
| "content-type": "text/html; charset=utf-8", | |
| }, | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment