Skip to content

Conversation

@alexanderjhughes
Copy link

What was changed

  • A basePath check was added to Solito's useLink method

Why this is needed

When configuring a basePath for your app using the NextJs basePath config, Solito for the most part uses it. There is one exception though. That is when Solito's useLink is called and the href is generated. If you click on the element, the onPress takes care of the basePath due to it using NextJs' router under the hood. However, the href is just passed down to the button without NextJs touching it. This fixes that issue.

Screencast.from.02-19-2025.11.39.00.PM.webm

In this screen recording, you can see it going to the correct url. The code for the url is as follows:

import {Button, YStack} from 'tamagui';
import {Layout} from '../../components';
import {useLink} from 'solito/link';

const EventsHomePage = () => {
  const buttonParams = useLink({
    href: '/search',
  });
  return (
    <Layout>
      <YStack jc={'center'} ai={'center'} mt={'$10'} h={'100%'}>
        <Button {...buttonParams}>Click me to go to search</Button>
      </YStack>
    </Layout>
  );
};

export default EventsHomePage;

In this you can see I am not adding the /app route, but now with this change, Solito adds it for me.

@vercel
Copy link

vercel bot commented Feb 20, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
solito-app ❌ Failed (Inspect) Feb 20, 2025 4:43am
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
solito ⬜️ Ignored (Inspect) Visit Preview Feb 20, 2025 4:43am

@nandorojo
Copy link
Owner

nandorojo commented Mar 19, 2025

Interesting. This seems correct but let me ask around to be sure. Thank you!

@nandorojo
Copy link
Owner

Shouldn't this get handled within onPress?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants