@@ -24,26 +24,26 @@ Add a file at `desktop/index.js` to run the electron app. The `initRemix` functi
2424
2525``` ts
2626// desktop/index.js
27- const { initRemix } = require (" remix-electron" );
28- const { app, BrowserWindow } = require (" electron" );
29- const { join } = require (" node:path" );
27+ const { initRemix } = require (" remix-electron" )
28+ const { app, BrowserWindow } = require (" electron" )
29+ const { join } = require (" node:path" )
3030
3131/** @type {BrowserWindow | undefined} */
32- let win;
32+ let win
3333
3434app .on (" ready" , async () => {
3535 try {
3636 const url = await initRemix ({
3737 serverBuild: join (process .cwd (), " build/index.js" ),
38- });
38+ })
3939
40- win = new BrowserWindow ({ show: false });
41- await win .loadURL (url );
42- win .show ();
40+ win = new BrowserWindow ({ show: false })
41+ await win .loadURL (url )
42+ win .show ()
4343 } catch (error ) {
44- console .error (error );
44+ console .error (error )
4545 }
46- });
46+ })
4747```
4848
4949Build the app with ` npm run build ` , then run ` npx electron desktop/index.js ` to start the app! 🚀
@@ -56,18 +56,18 @@ To circumvent this, create a `electron.server.ts` file, which re-exports from el
5656
5757``` ts
5858// app/electron.server.ts
59- import electron from " electron" ;
60- export default electron ;
59+ import electron from " electron"
60+ export default electron
6161```
6262
6363``` ts
6464// app/routes/_index.tsx
65- import electron from " ~/electron.server" ;
65+ import electron from " ~/electron.server"
6666
6767export function loader() {
6868 return {
6969 userDataPath: electron .app .getPath (" userData" ),
70- };
70+ }
7171}
7272```
7373
@@ -82,7 +82,7 @@ function createWindow() {
8282 webPreferences: {
8383 nodeIntegration: true ,
8484 },
85- });
85+ })
8686}
8787```
8888
@@ -110,17 +110,17 @@ Options:
110110** app/context.ts**
111111
112112``` ts
113- import type * as remix from " @remix-run/node" ;
113+ import type * as remix from " @remix-run/node"
114114
115115// your context type
116116export type LoadContext = {
117- secret: string ;
118- };
117+ secret: string
118+ }
119119
120120// a custom data function args type to use for loaders/actions
121121export type DataFunctionArgs = Omit <remix .DataFunctionArgs , " context" > & {
122- context: LoadContext ;
123- };
122+ context: LoadContext
123+ }
124124` ` `
125125
126126**desktop/main.js**
@@ -133,13 +133,13 @@ const url = await initRemix({
133133 getLoadContext : () => ({
134134 secret: " 123" ,
135135 }),
136- });
136+ })
137137```
138138
139139In a route file:
140140
141141``` ts
142- import type { DataFunctionArgs , LoadContext } from " ~/context" ;
142+ import type { DataFunctionArgs , LoadContext } from " ~/context"
143143
144144export async function loader({ context }: DataFunctionArgs ) {
145145 // do something with context
0 commit comments