github wasp-lang/wasp v0.11.3

latest releases: v0.14.2, v0.14.1, v0.14.1-rc2...
12 months ago

🎉 [New Feature] Type-safe links

Wasp now offers a way to link to pages in your app in a type-safe way. This means that you can't accidentally link to a page that doesn't exist, or pass the wrong arguments to a page.

After you defined your routes:

route TaskRoute { path: "/task/:id", to: TaskPage }

You can get the benefits of type-safe links by using the Link component from @wasp/router:

import { Link } from '@wasp/router'

export const TaskList = () => {
  // ...

  return (
    <div>
      {tasks.map((task) => (
        <Link
          key={task.id}
          to="/task/:id"
      {/* 👆 You must provide a valid path here */} 
          params={{ id: task.id }}>
      {/* 👆 All the params must be correctly passed in */}   
          {task.description}
        </Link>
      ))}
    </div>
  )
}

You can also get all the pages in your app with the routes object:

import { routes } from '@wasp/router'

const linkToTask = routes.TaskRoute({ params: { id: 1 } })

🐞 Bug fixes

  • Fixes API types exports for TypeScript users.
  • Default .gitignore that comes with new Wasp project (wasp new) is now more aggressive when ignoring .env files, ensuring they don't get committed by accident (wrong name, wrong location, ...).

Don't miss a new wasp release

NewReleases is sending notifications on new releases.