# @spark-web/next-utils

> --- title: Next.js Utils isExperimentalPackage: true ---

Latest version **5.1.0** (published 2026-01-15) · 0 weekly downloads

## Install

```sh
npm install @spark-web/next-utils
pnpm add @spark-web/next-utils
yarn add @spark-web/next-utils
bun add @spark-web/next-utils
```

## Health

**Score 55/100 (C)** — status: stable.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 5.1.0 |
| Published | 2026-01-15 |
| First published | 2022-04-20 |
| Weekly downloads | 0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=18.17 |
| Dependencies | 4 |
| Unpacked size | 28.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | brighte, brighte-release-bot |

## Links

- npm: https://www.npmjs.com/package/@spark-web/next-utils
- Repository: https://github.com/brighte-labs/spark-web
- Homepage: https://github.com/brighte-labs/spark-web#readme
- Issues: https://github.com/brighte-labs/spark-web/issues
- npm.io page: https://npm.io/package/@spark-web/next-utils

## Dependencies (4)

- [@babel/runtime](https://npm.io/package/@babel/runtime.md) ^7.25.0
- [@emotion/react](https://npm.io/package/@emotion/react.md) ^11.14.0
- [@spark-web/ssr](https://npm.io/package/@spark-web/ssr.md) 5.0.0
- [@spark-web/link](https://npm.io/package/@spark-web/link.md) ^5.1.0

## Recent versions

- 5.1.0 (latest) — 2026-01-15
- 5.1.0-rc.0 (rc) — 2025-07-24
- 0.0.0-snapshot-release-20220907053343 (snapshot-release) — 2022-09-07
- 5.0.0 — 2025-02-10
- 5.0.0-rc.31 — 2025-02-10
- 5.0.0-rc.29 — 2025-02-06
- 5.0.0-rc.28 — 2025-02-06
- 5.0.0-rc.27 — 2025-02-05
- 5.0.0-rc.26 — 2025-02-05
- 5.0.0-rc.25 — 2025-01-31
- 5.0.0-rc.24 — 2025-01-20
- 2.0.0-rc.21 — 2025-01-07
- 2.0.0-rc.20 — 2025-01-07
- 2.0.0-rc.19 — 2024-12-12
- 2.0.0-rc.18 — 2024-12-12
- … 32 more at https://npm.io/package/@spark-web/next-utils/versions

## README

---
title: Next.js Utils
isExperimentalPackage: true
---

## Universal Next Link

Resolves internal links using the
[Next.js Link component](https://nextjs.org/docs/api-reference/next/link), which
expects `href` to begin with a slash e.g. `href="/page"`. Uses a traditional
anchor element for everything else e.g. external, hash, tel, mailto.

For compatibility with TS + Spark the `href` property may only accept a string,
so URL Objects must be resolved ahead of time. We recommend the
[url package](https://www.npmjs.com/package/url) for complex cases, though most
of the time it's simple to do this manually.

You can pass the `UniversalNextLink` component to the `linkComponent` prop of
the `SparkProvider` and all `Link`, `TextLink`, and `ButtonLink` components will
automatically use the Next.js Link component for client-side transitions.

```jsx
import { SparkProvider } from '@spark-web/core';
import { UniversalNextLink } from '@spark-web/next-utils';

export default function App({ Component, pageProps }) {
  return (
    <SparkProvider linkComponent={UniversalNextLink}>
      <Component {...pageProps} />
    </SparkProvider>
  );
}
```

### Props

| Prop | Type   | Default | Description                                                                             |
| ---- | ------ | ------- | --------------------------------------------------------------------------------------- |
| href | string |         | URL to direct to. Note that the URL needs to be an internal link (i.e. `href='/page'`). |

The `UniversalNextLink` props also includes HTML `a` anchor props and are not
listed above.

## propsWithCssText

Function that takes the `initialProps` from `getInitialProps` and inlines
critical CSS server-side.

```jsx
import { propsWithCssText } from '@spark-web/next-utils';
import NextDocument, { Head, Html, Main, NextScript } from 'next/document';

export default class Document extends NextDocument {
  static async getInitialProps(context) {
    const initialProps = await NextDocument.getInitialProps(context);
    return propsWithCssText(initialProps);
  }

  render() {
    return (
      <Html>
        <Head />
        <body>
          <Main />
          <NextScript />
        </body>
      </Html>
    );
  }
}
```

### Props

| Prop         | Type                 | Default | Description                                                                                           |
| ------------ | -------------------- | ------- | ----------------------------------------------------------------------------------------------------- |
| initialProps | DocumentInitialProps |         | Value returned from the `getInitialProps` static method on the `Document` class (in `next/document`). |

---
_Source: https://npm.io/package/@spark-web/next-utils · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
