Skip to content

Need help connecting node backend. #12337

Closed Answered by FabianLars
ZaidSunasra asked this question in Q&A
Discussion options

You must be logged in to vote

In that case you can either add step 5 https://v2.tauri.app/learn/sidecar-nodejs/#execute-the-sidecar to index.ts / main.ts (using command.spawn() instead of execute) if you don't need it connected to react (like useState or whatever). Or in your app.ts file you can add it with an onMount hook for example like this

// Using example from https://v2.tauri.app/reference/javascript/shell/#example-1
const App = () => {
  useEffect(() => {
    const command = Command.sidecar('binaries/app', ["args", "if", "any"]);
    command.on('close', data => {
      console.log(`command finished with code ${data.code} and signal ${data.signal}`)
    });
    command.on('error', error => console.error(`comman…

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@ZaidSunasra
Comment options

@FabianLars
Comment options

@ZaidSunasra
Comment options

@FabianLars
Comment options

Answer selected by ZaidSunasra
@ZaidSunasra
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants