rsnext/packages/next/client
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
..
components Hybrid App Hooks Support (#41767) 2022-10-31 20:13:27 -07:00
dev Ignore serverComponentChanges in pages (#41464) 2022-10-16 21:34:33 +00:00
legacy Optimize bundle size for appDir (#42252) 2022-10-31 17:50:35 +00:00
portal refactor(portal): remove useRef from portal component (#39792) 2022-08-21 09:39:43 +00:00
add-base-path.ts Extract router utils to common functions (#37313) 2022-05-30 20:19:37 +02:00
add-locale.ts Extract router utils to common functions (#37313) 2022-05-30 20:19:37 +02:00
app-bootstrap.js Load beforeInteractive scripts properly without blocking hydration (#41164) 2022-10-09 15:08:51 +00:00
app-index.tsx Optimize bundle size for appDir (#42252) 2022-10-31 17:50:35 +00:00
app-next-dev.js Load beforeInteractive scripts properly without blocking hydration (#41164) 2022-10-09 15:08:51 +00:00
app-next.js Merge app internal chunk into main chunk for layouts (#41902) 2022-10-27 16:50:46 -07:00
detect-domain-locale.ts Extract router utils to common functions (#37313) 2022-05-30 20:19:37 +02:00
get-domain-locale.ts Extract router utils to common functions (#37313) 2022-05-30 20:19:37 +02:00
has-base-path.ts Extract router utils to common functions (#37313) 2022-05-30 20:19:37 +02:00
head-manager.ts Migrate head side effects to hooks (#37526) 2022-06-08 11:26:57 +00:00
image.tsx Optimize bundle size for appDir (#42252) 2022-10-31 17:50:35 +00:00
index.tsx Hybrid App Hooks Support (#41767) 2022-10-31 20:13:27 -07:00
link.tsx Hybrid App Hooks Support (#41767) 2022-10-31 20:13:27 -07:00
next-dev.js Add hard navigation guard and fix middleware rewrite cases (#37815) 2022-06-20 11:31:19 +00:00
next.js Split up & tweak next/client initialization (#33838) 2022-03-07 17:09:55 +00:00
normalize-locale-path.ts Extract router utils to common functions (#37313) 2022-05-30 20:19:37 +02:00
normalize-trailing-slash.ts Extract router utils to common functions (#37313) 2022-05-30 20:19:37 +02:00
page-loader.ts feat(next): Support has match and locale option on middleware config (#39257) 2022-08-31 11:23:30 -05:00
performance-relayer-app.ts Optimize bundle size for appDir (#42252) 2022-10-31 17:50:35 +00:00
performance-relayer.ts add attribution to web vitals (#39368) 2022-10-04 00:17:30 +00:00
remove-base-path.ts Extract router utils to common functions (#37313) 2022-05-30 20:19:37 +02:00
remove-locale.ts Extract router utils to common functions (#37313) 2022-05-30 20:19:37 +02:00
request-idle-callback.ts upgrade to typescript 4.4.3 (#29112) 2021-09-16 18:06:57 +02:00
route-announcer.tsx Hybrid App Hooks Support (#41767) 2022-10-31 20:13:27 -07:00
route-loader.ts feat(next): Support has match and locale option on middleware config (#39257) 2022-08-31 11:23:30 -05:00
router.ts Hybrid App Hooks Support (#41767) 2022-10-31 20:13:27 -07:00
script.tsx Bundle ssr client layer excepts react externals (#41606) 2022-10-22 16:33:51 -07:00
trusted-types.ts Route Loader Trusted Types Violation Fix (#34730) 2022-05-03 23:22:08 +00:00
use-intersection.tsx refactor(use-intersection): remove useRef usage (#39791) 2022-08-21 10:10:09 +00:00
with-router.tsx Upgrade typescript to 4.8.2 (#39979) 2022-08-29 16:56:02 +00:00