Skip to content

Releases: molefrog/wouter

Dual publish

30 Jul 11:16
Compare
Choose a tag to compare

This release aims to fix a problem when a subpath module require("wouter/static-location") can't be properly required from Node.js, thanks @davidje13 #126

Wouter now properly supports ESM and CommonJS environments and it can even work within .mjs scripts!

A route to extendability

19 Jul 10:54
Compare
Choose a tag to compare

✨ The new release brings up several important updates!

  • The new project logo, thanks to Katya Simacheva

  • Released in 2.5.1 Wouter now targets ESM Node modules and properly supports CJS submodules. #126 thanks @davidje13

  • Using a default route in a Switch just became easier: use <Route /> component with no props and it will match everything that didn't match regular routes. @cbbfcd via #103

<Switch>
  <Route path="/users> ... </Route>
- <Route path="/:rest*">
+ <Route>
    Not Found!
  </Route>
</Switch>

check out the Demo →

  • Static location hook now supports record: option, which allows to save the history of location changes in hook.history. It improves the testing DX and allows to detect redirects in SSR responses. #113, thanks @davidje13
  • Link and Redirect components now can accept replace option that will tell wouter that replaceState navigation should be used. Example:
<Link to="/users" replace>Users</Link>
<Redirect to="/home" replace />
  • Some tiny updates in the README: table of contents for better navigation, more examples, testimonials! It's such an honor to see that wouter's community is getting bigger and developers trust it in production:
    image

  • The entire type definition codebase had been reworked! Types are updated to support latest features like default routes and replace navigation, and to support custom location hooks that might have specific navigational options. This change is especially important in terms of wouter's new strategy: supporting new features through external extendability see #102 (comment).

This will allow us to easily implement custom location hooks, that can for example support state changes:

import { useLocation } from "wouter";
import useLocationWithState, { LocationWithState }  from '@wouter/use-location-state';

const NavigateWithState = () => {
  // useLocation is a generic function that can accept the custom location hook type
  const [location, update] = useLocation<LocationWithState>();
  
  const onClick = useCallback(() => {
    // this is now a valid function call, `state:` option is included in LocationWithState type
    update("/home", state: { foo: "bar" });
  }, [update]);

  return null;
}

const App = () => (
  <Router hook={useLocationWithState}>
    <Link<LocationWithState> to="/app" state={{ foo: 'bar' }}>Click Me!</Link>
  </Router>
);

First-class base path support!

19 Nov 19:00
Compare
Choose a tag to compare

Though the base path support was possible before, via a custom useLocation hook, it wasn't fully SEO-friendly — for example, the link would still have a relative href attribute.

After a long discussion, it's been decided to enable the base path support on a top-level Router component 🎉 You can now just wrap your app with <Router base="/app"> and that's it! Learn more about this feature →

The added bundle cost is just 48 extra bytes.

@omgovich @cbbfcd @guiem via #76

Preact 10.0, generic types and missing updates

10 Oct 12:04
Compare
Choose a tag to compare
  • Wouter now is fully-compatible with Preact 10.0! You can install Preact version via npm install wouter-preact #88, thanks @developit
  • Type definitions now support generics, handy if you want to specify a shape of props your component accepts #87, thanks @ArnaudBarre
  • useLocation now also catches updates that may happens between the initial render and useEffect call. See #85
  • Redirect component now uses useLayoutEffect to trigger the update as soon as possible and prevent apps from flicker.

Types, types, types... and Preact-only package!

12 Aug 15:56
Compare
Choose a tag to compare

Improvements:

  • TypeScript types are now bundled with the library, including types for React and wouter/preact! Types are properly tested and can be maintained in the same repo. Thanks to @Ty3uK @StrayFromThePath and @polRk
  • Wouter now comes with a standalone package with Preact-only version: npm install wouter-preact. This makes it possible to use proper peerDependecies, and stop relying on React in your project #48 #49 cc/ @cedeber
  • 2nd argument of useLocation is now properly cached #74 #69 cc/ @neves
  • Links do not fire navigation when click using modifier keys like ctrl or ⌘ #68 thanks @marvinhagemeister
  • setLocation now supports a 2nd argument which allows to perform replaceState navigation (@Ty3uK via #52):
setLocation('/about', true); // calls replaceState instead of pushState

v2.1.1

08 Jul 16:37
Compare
Choose a tag to compare

Bugfixes:

  • Fix Route/Switch dynamic segments rendering bug #45 / @jeetiss

v2.1.0

28 Jun 15:43
Compare
Choose a tag to compare

Improvements:

  • Implicit routers are always created once #44
  • useLocation accepts router as an argument #44
  • Proper dependencies in useEffect, code only runs on mount/unmount #41 @jeetiss
  • Matcher refactoring #42 @jeetiss

v1.3.2

30 May 11:33
Compare
Choose a tag to compare

Bugfixes:

  • Adds react-deps.js to the list of files to publish #34

Preact is there!

27 May 09:11
Compare
Choose a tag to compare

New functionality:

  • Added a support for Preact #29 Thanks @StrayFromThePath!

v1.2.3

13 May 20:49
Compare
Choose a tag to compare

Bugfixes:

  • Fixes a critical typo in <Link /> component which resulted being unable to customize the link element #26