rsnext/packages/next/shared/lib
Wyatt Johnson 6c7e76b551
Hybrid App Hooks Support (#41767)
This adapts the new client hooks of `usePathname`, `useSearchParams`,
and `useRouter` to work within the `pages/` directory to aid users
attempting to migrate shared components over to the `app/` directory.

> **Exception:**
> When the pages router is not ready, `useSearchParams` will return an
empty `URLSearchParams`. This mirrors the behavior seen in the `pages/`
directory today in that `router.query` is not available until the client
hydrates.

This also adds a new option for `useRouter` to bring it line with the
correct typings with the app directory. By default, calling
`useRouter()` will return the type `NextRouter | null` to represent what
you get when you call it from a component originating from the app
directory. If you want to instead force it to return `NextRouter` as it
does today, you can pass a boolean into the `useRouter` call as such:

```ts
const router = useRouter()     // typeof router === NextRouter | null
const router = useRouter(true) // typeof router === NextRouter
```

This change is designed to ease the incremental adoption of app.
2022-10-31 20:13:27 -07:00
..
i18n Enable @typescript-eslint/no-use-before-define for functions (#39602) 2022-08-15 10:29:51 -04:00
isomorphic polish isomorphic path module (#36521) 2022-04-27 18:23:26 +00:00
page-path Bypass empty pages folder for layouts (#40132) 2022-09-03 00:13:47 +00:00
router Hybrid App Hooks Support (#41767) 2022-10-31 20:13:27 -07:00
utils Optimize bundle size for appDir (#42252) 2022-10-31 17:50:35 +00:00
amp-context.ts Move code shared between server/client to "shared" folder (#26734) 2021-06-30 11:43:31 +02:00
amp-mode.ts Fix bloat in main bundle from amp (#37383) 2022-06-02 00:21:09 +00:00
amp.ts Fix bloat in main bundle from amp (#37383) 2022-06-02 00:21:09 +00:00
app-router-context.ts Hybrid App Hooks Support (#41767) 2022-10-31 20:13:27 -07:00
constants.ts Merge app internal chunk into main chunk for layouts (#41902) 2022-10-27 16:50:46 -07:00
dynamic.tsx Remove react root condition and always use concurrent mode (#42141) 2022-10-29 20:34:03 +00:00
escape-regexp.ts perf(escapeStringRegexp): test before replace (#34472) 2022-04-16 05:42:10 +00:00
flatten.ts Refactor Page Paths utils and Middleware Plugin (#36576) 2022-04-30 11:19:27 +00:00
get-hostname.ts Execute middleware on Next.js internal requests (#37121) 2022-05-27 13:29:04 -05:00
head-manager-context.ts Load beforeInteractive scripts properly without blocking hydration (#41164) 2022-10-09 15:08:51 +00:00
head.tsx Optimize bundle size for appDir (#42252) 2022-10-31 17:50:35 +00:00
hooks-client-context.ts Hybrid App Hooks Support (#41767) 2022-10-31 20:13:27 -07:00
html-context.ts Add support for font loaders (#40746) 2022-09-21 22:12:59 -07:00
image-blur-svg.ts Fix next/image svg blur placeholder with fill (#41573) 2022-10-19 13:21:41 -07:00
image-config-context.ts fix: make sure image-config gets transpiled (#34677) 2022-02-22 09:27:18 -05:00
image-config.ts feat: set a better type for the default image loader (#41639) 2022-10-24 23:59:07 +00:00
image-loader.ts feat: set a better type for the default image loader (#41639) 2022-10-24 23:59:07 +00:00
is-plain-object.ts Use Edge Runtime for running Edge Functions locally (#37024) 2022-05-30 12:01:36 +00:00
loadable-context.ts Move code shared between server/client to "shared" folder (#26734) 2021-06-30 11:43:31 +02:00
loadable.d.ts Hybrid App Hooks Support (#41767) 2022-10-31 20:13:27 -07:00
loadable.js Remove react root condition and always use concurrent mode (#42141) 2022-10-29 20:34:03 +00:00
match-remote-pattern.ts Fix experimental remotePatterns wildcard (#37137) 2022-05-25 20:25:06 +00:00
mitt.ts Move code shared between server/client to "shared" folder (#26734) 2021-06-30 11:43:31 +02:00
router-context.ts Hybrid App Hooks Support (#41767) 2022-10-31 20:13:27 -07:00
runtime-config.ts Move code shared between server/client to "shared" folder (#26734) 2021-06-30 11:43:31 +02:00
server-inserted-html.tsx Dont apply existing externals path changing to rsc layers (#41744) 2022-10-24 18:00:44 -07:00
side-effect.tsx Upgrade typescript to 4.8.2 (#39979) 2022-08-29 16:56:02 +00:00
styled-jsx.d.ts Remove precopied styled-jsx (#39520) 2022-08-12 17:08:38 +00:00
styled-jsx.js Remove precopied styled-jsx (#39520) 2022-08-12 17:08:38 +00:00
utils.ts Optimize bundle size for appDir (#42252) 2022-10-31 17:50:35 +00:00