Skip to content

A lightweight Angular library that wraps `HttpClient` to enable seamless state transfer for SSR/CSR apps.

Notifications You must be signed in to change notification settings

Ayan-Kumar-Saha/ngx-transmission

Repository files navigation

ngx-transmission

A lightweight Angular library that wraps HttpClient to handle origin issues and enable seamless state transfer for SSR/CSR apps.

✨ Features

  • ✅ Provides a simple, reusable HTTP service
  • ✅ Works out-of-the-box with Angular SSR (Universal)
  • ✅ Handles origin header injection on server-side
  • ✅ Pluggable for custom logic

📦 Installation (not yet published)

pnpm add ngx-transmission
# or
npm install ngx-transmission

📦 Usage

  1. Import the module in your AppModule (Browser)
//app.module.ts

@NgModule({
  imports: [
	...,
    NgxTransmissionModule.forRoot({
      origin: 'http://localhost:3000' // required only for SSR
    })
  ]
})
export class AppModule {}

and in your AppServerModule (Server)

//app.module.server.ts

@NgModule({
  imports: [
	...
	NgxTransmissionModule.forRoot({ 
		origin: 'http://localhost:4200' // required only for SSR
	})
  ],
  bootstrap: [AppComponent],
})

2. Use the service in your components

@Component({...})
export class ExampleComponent {

  constructor(
	private api: NgxTransmissionService
  ) {}

  ngOnInit() {
    this.api
	.get('/api/posts')
	.subscribe(console.log);
  }
}

🔧 Roadmap

  • Add TransferState integration

  • Add life cycle hooks support

  • Add request/response caching

  • Provide better type-safe options wrapper

About

A lightweight Angular library that wraps `HttpClient` to enable seamless state transfer for SSR/CSR apps.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published