# rocket-url

> This module return the real custom host when you are using AWS Amplify with custom domains on Next JS using Server Side Rendering.

Latest version **1.1.0** (published 2023-01-25) · ISC license · 0 weekly downloads

## Install

```sh
npm install rocket-url
pnpm add rocket-url
yarn add rocket-url
bun add rocket-url
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2023-01-25 |
| First published | 2023-01-25 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 2.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Cristopher Coopman |
| Maintainers | ccoopman |
| Keywords | nextjs, next-js, next, react, ssr, serversiderendering, server-side-rendering, getInitialProps, getServerSideProps, aws, amplify |

## Links

- npm: https://www.npmjs.com/package/rocket-url
- npm.io page: https://npm.io/package/rocket-url

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.1.0 (latest) — 2023-01-25
- 1.0.8 — 2023-01-25
- 1.0.7 — 2023-01-25
- 1.0.6 — 2023-01-25
- 1.0.5 — 2023-01-25
- 1.0.4 — 2023-01-25
- 1.0.3 — 2023-01-25
- 1.0.2 — 2023-01-25
- 1.0.1 — 2023-01-25
- 1.0.0 — 2023-01-25

## README

This module return the real custom host when you are using AWS Amplify with custom domains on Next JS using Server Side Rendering.

## Import module

import rocketUrl from 'rocket-url'

## On getInitialProps
## receive 'ctx' from AppContext NextJS

App.getInitialProps = async ({ ctx }) => {
    const { host, protocol, origin } = rocketUrl(ctx?.req)

    return {
        props: {
            host,
            protocol,
            origin
        }
    }
}

## On getServerSideProps
## receive 'req' from AppContext NextJS

export async function getServerSideProps({ req, resolvedUrl }) {
    const { host, protocol, origin } = rocketUrl(req)
    const pathname = resolvedUrl

    return {
        props: {
            host,
            protocol,
            origin,
            pathname
        }
    }
}

---
_Source: https://npm.io/package/rocket-url · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
