Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SSR support #6

Open
Gounlaf opened this issue Apr 17, 2021 · 1 comment
Open

SSR support #6

Gounlaf opened this issue Apr 17, 2021 · 1 comment
Labels
enhancement New feature or request

Comments

@Gounlaf
Copy link

Gounlaf commented Apr 17, 2021

Hi,

I've just discovered your library and I really think It worth to try it :)

I'm facing issue with Next.js compatibility. So I quickly tried with a CRA, it does work without any problem

import logo from './logo.svg';
import './App.css';

import {Orion} from "@tailflow/laravel-orion/lib/orion";

Orion.init('https://your-api.test');
Orion.setToken('access-token-here');

function App() {
  console.debug(Orion.getToken())// Will output 'access-token-here' as expected

  return (
    <div className="App">[...]</div>
  );
}

export default App;

With a Next.js, I got the error SyntaxError: Cannot use import statement outside a module.

Some related issues:

Digging deeper, I found this: https://stackoverflow.com/questions/62422174/cannot-use-import-statement-outside-a-module-with-next-js (answer: https://stackoverflow.com/a/62423865/2098861) ;
Related issue, if I understand it correctly:

Could you take a look and make your library compatible both server&client side (if it's not really the case)?

In the meantime, I'm trying the "dynamic" imports or "useEffect" with import inside (found in related issues linked above).

I don't know how to help more, but ask if you need more details / help / reproducible example...

Thanks,

Regards.

Edit: looking further, it seems that the problem is more on next.js side than on libraries...

@alexzarbn
Copy link
Member

Hi @Gounlaf,

Thank you for raising this issue. Indeed, SSR is something I have totally missed! The goal of this SDK is to provide a complete solution for consuming Orion-powered REST APIs, whether it be from a client, or a server side.

That being said, I will look into providing support for SSR in the next releases ✨

@alexzarbn alexzarbn changed the title [Compat] Compatibility with Next.js? SSR support Apr 19, 2021
@alexzarbn alexzarbn added the enhancement New feature or request label Apr 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants